0
我已将REST服务迁移到Azure网站,但它始终以400.0 Bad Request
错误(错误代码为零)返回。400.0对Azure网站上的REST API的错误请求
该服务在本地运行,并且在Web角色中运行时完美运行。进入网站后,它开始回到400.0错误。
我的web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" />
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
我已经ASP.NET兼容性在我的班级设置:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class BookingService { ... }
和Global.asax.cs中定义的正确的路由:
private void Application_Start (object sender, EventArgs e) {
RouteTable.Routes.Add(new ServiceRoute("booking/service", new WebServiceHostFactory(), typeof(BookingService)));
}
现在,当我尝试本地访问REST API时,它工作正常:
http://localhost/booking/service/help
然而,上载网络服务为Azure的网站和做后:
http://xxx.azurewebsites.net/booking/service/help
它回来了400.0错误的请求。详细的错误日志显示:
Request: ManagedPipelineHandler
Notification: ExecuteRequestHandler
Handler: System.ServiceModel.Activation.AspNetRouteServiceHttpHandler
Error code: 0x00000000
我在总损失。谷歌搜索没有产生任何帮助。我试图把以下内容web.config中:
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="Foo.RoutingHandler" />
</handlers>
,并通过扩展UrlRoutingHandler
和定义VerifyAndProcessRequest
定义的处理程序,但它仍然无法正常工作。