【发布时间】:2018-08-20 01:23:27
【问题描述】:
尝试将旧版 Web 应用程序从 IIS8 移动到 Azure Web 应用程序。该应用程序包含许多对 WCF 服务的 ajax 调用,这些调用是在没有端点配置的情况下构建的,类似于此处描述的方法:http://stevemichelotti.com/restful-wcf-services-with-no-svc-file-and-no-config/
正如文章中所建议的,System.Web.Routing 用于将请求路由到正确的服务。例如,我的 global.asax 包含这样的路由:
RouteTable.Routes.Add(new ServiceRoute("svc/cmp/", new WebServiceHostFactory(), typeof(CompanyService)));
RouteTable.Routes.Add(new ServiceRoute("svc/cont/", new WebServiceHostFactory(), typeof(ContactsService)));
因此,http://example.com/svc/cmp/GetCompany?id=1234 的请求将被路由到 CompanyService 进行处理。
这些调用在 IIS 上运行时都可以正常工作,但在 Azure Web 应用程序上返回 404 not found 错误。
我尝试将处理程序添加到 web.config,如下所示:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
还尝试在 Azure 应用设置中添加处理程序映射,以使所有扩展 (*) 由 %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll 处理。
这两种情况都没有运气。
【问题讨论】: