是否可以保留以下地址并使用ServiceStack重新实现?
http://example.com/Routing/LeadPost.aspx?LeadType=AAA&MYId=3000
我无法访问原始代码,因为它是创建它的第三方,但我确实知道它的帖子,一个巨大的xml包。我完全模仿了干净的DTO请求和服务,但我不清楚寻址部分,或者它是否合理。以下是我到目前为止的实施情况。
public class Service : ServiceStack.Service
{
public IMessageQueueClient MessageQueueClient { get; set; }
public object Post(LeadInformation request)
{
if (request == null) throw new ArgumentNullException("request");
var sw = Stopwatch.StartNew();
MessageQueueClient.Publish(request);
return new LeadInformationResponse
{
TimeTakenMs = sw.ElapsedMilliseconds,
};
}
}
谢谢你, 斯蒂芬
答案 0 :(得分:1)
您可以使用此路由定义来处理旧版ASP.NET WebForms请求:
[Route("/Routing/LeadPost.aspx")]
public class LegacyLeadPost
{
public string LeadType { get; set; }
public int MyId { get; set; }
}
这将让您处理填充了LeadType
和MyId
属性所需的路线:
/Routing/LeadPost.aspx?LeadType=AAA&MYId=3000
另一种方法是使用WebForms页面并调用ServiceStack,ServiceStack Integration文档探讨了从外部ASP.NET MVC或WebForms Web框架访问ServiceStack的不同方法。
答案 1 :(得分:0)
当您安装ServiceStack(至少版本3,这是我上次使用的版本)时,它会为您的应用程序Web.Config file
添加一些内容,如下所示:
<system.web>
<httpHandlers>
<add path="somePath/*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
如果您修改path
属性以匹配旧网址,则可能会有效。然后,再次,不知道为您的应用程序设置了什么其他HttpHandler
,是不可能确定的。另请注意,您可能会引入冲突,因为有一个HttpHandler
将所有.aspx
网址传递给.NET webforms Page
基类以及所有其他代码隐藏文件应用