Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 works as desired but the client does not have the ability to add the .asmx extension, or any extension for that matter, in their calls. They basically use http://localhost/soap/MyWebService while IIS expects http://localhost/soap/MyWebService.asmx. Is there any way to make IIS respond to requests without the .asmx extension?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
540 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...