This is for those who want to do this. It was very difficult for me to find information.
In the method GetHttpHandler(byVal requestContext as RequestContext) as IHttpHandler Implements IRouteHandler.GetHttpHandler (my version is higher)
This is for Webforms 3.5, by the way (mine in VB).
You cannot use the usual BuildManager.CreateInstanceFromVirtualPath () method to call your web service only for those things that implement iHttpHandler, which is missing .asmx. Instead, you need to:
Return New WebServiceHandlerFactory().GetHandler( HttpContext.Current, "*", "/VirtualPathTo/myWebService.asmx", HttpContext.Current.Server.MapPath("/VirtualPathTo/MyWebService.aspx"))
The MSDN documentation says that the third parameter should be RawURL, passing HttpContext.Current.Request.RawURL does not work, but passing the virtual path to the .asmx file instead works fine.
I use this functionality so that my web service can be called by any website configured anyway (even a virtual directory) that points (in IIS) to my application, which can call the application web service using something something like " http: // url / virtualdirectory / anythingelse / WebService ", and routing will always route this to my .asmx file.
Markive
source share