Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
76
rated 0 times [  79] [ 3]  / answers: 1 / hits: 52988  / 12 Years ago, tue, november 6, 2012, 12:00:00

I am trying to host an ASP.NET MVC4 web application with IIS 7.5. When debugging the app everything works fine (I'm assuming this is because of Windows Authentication).
However, when I publish the app and browse to it I get a 405 Method not allowed error:



POST http://localhost/ 405 (Method Not Allowed)
send
i.extend.ajax
i.(anonymous function)
(anonymous function)


From what I've been reading this is either a problem with the Handler Mappings in IIS or some configuration is needed in the web.config. Either way, I have not found the correct solution.
Could anyone tell me what my web.config should include to all POSTS? And/or how to set up the correct Handler mapping in IIS, as I am new to web development and find the number of options a bit overwhelming.



The piece of javascript that throws the error is the following:



$.post(/, { latitude: locLat, longitude: locLon, username: $('#onlineUsers').attr('itemid') });

More From » jquery

 Answers
13

A 405 is thrown by IIS when an HTTP verb(GET,PUT,POST,DELETE,HEAD,etc.) is requested and is not supported/disallowed by the designated handler.



You'll need to open the IIS manager -> Default Web Site -> Handler Mappings (Or the handler mappings specific to your web-application)



enter



In here you'll need to play with the handler mappings as one of them is not allowing POST verbs.



As you are not posting to any specific page (.aspx, .ashx, etc.), it will be difficult to identify the exact handler that is causing you issues.



Handlers of interest may be:




  • ExtensionlessUrlHandler-ISAPI-4.0_32bit /64bit

  • StaticFile



Once you identify the handler your request is being routed to, double click it to open the dialogue.



enter



From there click Request Restrictions then Verbs



Make sure the appropriate verb is present in the text area.



enter



As I mentioned before, I'm not sure which handler is handling your request as you are not posting to any particular page (you may have URL re-writing in place that is routing your request appropriately).






If the above fails, you may need to check if WebDAV Publishing is installed and remove it (restart required).



WebDAV


[#82151] Monday, November 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ronaldo

Total Points: 694
Total Questions: 85
Total Answers: 103

Location: Somalia
Member since Mon, Feb 27, 2023
1 Year ago
;