0

I am working on a component which uses xmlHttpRequest to get DOM element positions from a xml on the server. Than after drag and drop I update the xml with the new positions and I want to post it back via XMLHttpRequest to the server to update the same file.

The responseText message states that HTTP Error 405.0 - Method Not Allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

I checked the applicationhost.config file and looks like every handler is configured with POST method. Also turned on all the features of IIS on Win 7 components.

My pc: Win7 home basic, visual studio professional, iis 7.5 express.

p.e.: I don't use webrequest method since mainly using javascript for the update process, because of the drag and drop functionality of the mootools library.

Thank you in advance!

Kornel
  • 263
  • 4
  • 16
  • What's the handler written in? It sounds like either your javascript is fine but you've a bug in your handler, so it's the ASP.NET or PHP or whatever that you wrote that in that your problems lies at. – Jon Hanna Jan 25 '12 at 02:02
  • Hi Jon, my handler is not my handler actually, it was installed by the iis express installation process. If you want I can copy here the js code if you think it helps, but the only problem that I can presume is it something related with serialization of the xml or the format. – Kornel Jan 25 '12 at 14:14
  • By the way it is in asp.net, but as I mentioned in my original post it doesn't have any connection since 90% of visible processing happens in the js code. – Kornel Jan 25 '12 at 14:15
  • POSTing to something you should be able to POST to, and receiving a 405 suggests the issue is server side. Of course, maybe you're not POSTing due to some bug at that point. Have you looked at the request and response with Fiddler? – Jon Hanna Jan 25 '12 at 14:32
  • I looked with FireBug and the responseText is what I have mentioned in the post. I check it with fiddler and post back then. – Kornel Jan 25 '12 at 14:57
  • Checked with Fiddler, and got the same log that the iis provided. It is with the staticfilehandler which doesn't have the VERB 'POST', but particulary this handler is like that in the config file: – Kornel Jan 25 '12 at 15:39

3 Answers3

0

Is your component and the server handling the XMLHttpRequests served from the same origin? Ie. is it served from the same, protocol://host:port combination. If not, the browser will issue a HTTP OPTIONS instead of the POST you are expecting it to. To handle this situation either do:

JSONP

Cross-origin resource sharing

Trygve
  • 2,445
  • 1
  • 19
  • 23
  • Hello, I am closing this conversation since the issue was resolved with JSON request and object mapping via WebService. I assume the problem was a security one regarding to local permission configuration on the directory. Thank you for your help! Kornél – Kornel Apr 12 '12 at 11:21
0

I am closing this conversation since the issue was resolved with JSON request and object mapping via WebService. I assume the problem was a security one regarding to local permission configuration on the directory.

Thank you for your help!

Kornél

Kornel
  • 263
  • 4
  • 16
  • 1
    After 2 days of research, the only working solution I found to avoid "405 Method Not Allowed" was to define the CORS headers in the `Application_BeginRequest` method, as mentioned in this answer http://stackoverflow.com/a/14631068/827168 – pomeh Oct 15 '14 at 08:49
0

The configuration you mention in your comment, sets the default IIS modules for handling "static files", that is responding to GET requests by returning a file based on mapping the URI path to the file system.

These are set up to handle all verbs but to 405 to everything except GET and HEAD because that is the default IIS behaviour for "static files" is to refuse to allow them to be POSTed to (or PUT to, or DELETEd).

The bug therefore is that the URI you are POSTing to isn't mapping to your handler for dealing with the data the javascript is POSTing. If that handler is an ASPX page, then check that other ASPX pages are working and that the correct URI is used. Then try debugging it with a simple HTML form that POSTs appropriate data (or even inappropriate data so you can at least get an error message about the data being wrong rather than it ending up somewhere that refuses to handle POST at all).

If the code to handle the POST is in an IHttpModule or IHttpHandler, then you need to add something to the web.config to override the default for the URI(s) in question.

Jon Hanna
  • 110,372
  • 10
  • 146
  • 251