jQuery的POST,错误405不允许的方法 [英] jQuery POST, Error 405 Method not allowed

查看:1967
本文介绍了jQuery的POST,错误405不允许的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想举办与IIS 7.5的ASP.NET MVC4 Web应用程序。当调试应用程序的一切工作正常(我假设这是因为Windows身份验证)。
然而,当我发布应用程序和浏览它,我得到一个不允许的405方法错误:

  POST HTTP://本地主机/ 405(不允许的方法)
发送
i.extend.ajax
我(匿名函数)
(匿名函数)

这是我一直在阅读这或者是需要在web.config的处理程序映射在IIS或某些配置有问题。无论哪种方式,我还没有找到正确的解决方案。
谁能告诉我什么我的web.config应包括所有的帖子?和/或如何建立正确的处理程序映射在IIS中,因为我是新的网络开发和找到的选项有点势不可挡的数量。

这件作品的JavaScript抛出的错误是:

  $后(/,{纬度:locLat,经度:locLon,用户名:$('#onlineUsers')ATTR('为itemid')});


解决方案

一个405是由IIS时抛出一个HTTP动词(GET,PUT,POST,DELETE,HEAD等)请求,不支持/被禁止指定的处理程序。

您需要打开IIS管理器 - >默认网站 - >处理程序映射(特定于Web应用程序或处理程序映射)

在这里,你将需要与处理器映射其中之一是不允许POST动词玩。

由于你没有发布任何具体页面(的.aspx,.ashx的,等等),这将是很难确定导致您的问题的具体处理程序。

感兴趣的处理程序可能是:


  • ExtensionlessUrlHandler-ISAPI-4.0_32bit / 64

  • StaticFile

一旦你确定你的请求被发送到处理程序,双击它打开对话。

从那里,点击请求限制,然后动词

确认相应的动词是在文本区域present。

正如我前面提到的,我不知道哪个操作是处理你的要求,你没有张贴任何特定页面(您可能必须在适当的路由你的请求地方URL重写)。


如果上面的失败,您可能需要检查是否安装了WebDAV发布和删除(需要重新启动)。

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') });

解决方案

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)

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.

From there click "Request Restrictions" then "Verbs"

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

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).

这篇关于jQuery的POST,错误405不允许的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆