2

I seem to encounter a very specific problem, apologies for length of question.

I have a script service physically residing at /somepath/service.asmx. I am using a url rewriting module (UrlRewritingNet v2.0) to rewrite calls from /service.asmx to my physical location. This module uses .Net's HttpContext.RewritePath() functionality.

My service exposes method dosomething, and on my page there is a script call:

$.ajax({
  type: "POST",
  url: "/service.asmx/dosomething",
  data: JSON.stringify(inputData),
  contentType: "application/json; charset=utf-8",
  dataType: "json"
});

When I run this code in IIS - it returns status code 200, but when I run this code on VS dev server - it returns 405 Method Not Allowed. Error message from stack trace is:

"The HTTP verb POST used to access path '/somepath/service.asmx/dosomething' is not allowed."

Notice that in this message the path seems to be routed correctly.

The interesting thing is - I'm almost positive this is a routing issue, because when I change my ajax call to the full url /somepath/service.asmx/dosomething - both IIS and VS dev server work fine.

Any ideas how to avoid that 405?

tsemer
  • 2,959
  • 3
  • 29
  • 26
  • Check at which level the rewrite module sits in your iis pipeline. I got a feeling that rewriting is happening "after" hitting the asmx. Even more so since you said you are using a custom module. Adding a module to a project usually just appends it to the end of the stack. You will probably need to do a remove/add in your httpmodules section to get the order right. – Robert Hoffmann Nov 26 '12 at 19:17
  • What version and mode is your IIS? Your module may not actually be loaded unless you have the proper web.config sections for both classic and integrated modes. See the related section on [Creating and Registering a Custom HTTP Module](http://msdn.microsoft.com/en-us/library/ms227673(v=vs.100).aspx) – Jeremy Smith Nov 27 '12 at 01:50
  • Thanks @Robert and Jeremy Smith but (A) I've tested and my rewriting IS happening (makes sense considering my comment about the error message I'm getting - the URL there is rewritten properly); and (B) my fix would have nothing to do with IIS configuration, because the one that is failing is the VS Dev Server. – tsemer May 29 '13 at 11:53

0 Answers0