Call an IIS Web Service without the .asmx extension

前端 未结 4 1109
逝去的感伤
逝去的感伤 2020-12-10 20:48

I have written a .NET web Service that is to be consumed by a client outside of my control (my server is a simulator for a live server written in PHP). The web service work

4条回答
  •  难免孤独
    2020-12-10 21:12

    Add a wildcard mapping, which will route all requests through ASP.NET:

    http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx

    You'll also need to do some URL rewriting, to allow the incoming request http://localhost/soap/MyWebService to map to http://localhost/soap/MyWebService.asmx.

    http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

    Basically, you could add something like the following to your Application_BeginRequest method:

    string path = Request.Path;
    if (path.Contains("/soap/") && !path.EndsWith(".asmx"))
        Context.RewritePath(path + ".asmx");
    

    I haven't tested it (and it's a HACK) but it should get you started.

提交回复
热议问题