Reputation: 38485
Well im trying a simple
i have a simple web service like page containing
public partial class WebApi : System.Web.UI.Page
{
[WebMethod]
public static GetImageResult GetRandomImage()
...
i have added the following to "Global.asax.cs" (Application_BeginRequest)
string absolutePath = Request.Url.AbsolutePath.Substring(1);
if (absolutePath.StartsWith("WebApi/", StringComparison.OrdinalIgnoreCase))
{
Context.RewritePath("/WebApi.aspx/" + absolutePath.Substring(7));
}
but asp.net seems to have a problem with this the function is never called and javascript just reports "Method Not Allowed".
Is there some thing more i have to do to make this work?
Upvotes: 0
Views: 292
Reputation: 18794
I recommend using IIS Url Rewrite Module rather than trying to roll your own. It will intercept the request before it gets to your application, and provides a GUI for you to write and test the regular expression against your urls.
http://www.iis.net/download/URLRewrite
Upvotes: 1