jer*_*cra 3 .net iis web-services asmx
我编写了一个.NET Web服务,由我控制之外的客户端使用(我的服务器是用PHP编写的实时服务器的模拟器).Web服务按预期工作,但客户端无法在其调用中添加.asmx扩展名或任何扩展名.它们基本上使用http:// localhost/soap/MyWebService,而IIS需要http://localhost/soap/MyWebService.asmx.有没有办法让IIS响应没有.asmx扩展名的请求?
添加通配符映射,它将通过ASP.NET路由所有请求:
您还需要进行一些URL重写,以允许传入的请求http://localhost/soap/MyWebService映射到http://localhost/soap/MyWebService.asmx.
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
基本上,您可以在Application_BeginRequest方法中添加以下内容:
string path = Request.Path;
if (path.Contains("/soap/") && !path.EndsWith(".asmx"))
Context.RewritePath(path + ".asmx");
Run Code Online (Sandbox Code Playgroud)
我没有测试它(它是一个HACK)但它应该让你开始.