jQuery的AJAX后收到405错误(HTTP动词POST不允许) [英] jQuery AJAX post receives 405 error (HTTP verb POST not allowed)

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

问题描述

我有以下jQuery的岗位到ASP.NET的webmethod:

I have the following jQuery post to an ASP.NET webmethod:

$.ajax({
    type: "POST",
    url: "AjaxWebMethods.aspx/UpdNote",
    contentType: "application/json; charset=utf-8",
    data: "{'ID' : '" + id + "', 'note' : '" + note + "' }",
    dataType: "json",
    success: UpdNote_Success,
    error: AjaxError
});

和Web方法声明:

[System.Web.Services.WebMethod(enableSession: true)]
public static int UpdNote(int ID, string note) {
    // business logic that eventually returns a number, but simplifying
    // ... for the sake of brevity
    int retNum = 99;

    return retNum;
}

jQuery的职位,并在Windows身份验证的环境中Web方法既美妙的工作(即 - 用户通过LDAP身份验证)。不过,最近我的网站移动到使用RSA(双因素身份验证,PIN码和令牌code)对于以获得访问该网站的用户进行身份验证的服务器。而我所看到的是,现在我所有的jQuery的帖子正在返回405错误。

The jQuery post and the web method both work wonderful in a Windows Authenticated environment (ie - users are authenticated by LDAP). However, I recently had to move the website to a server that uses RSA (two-factor authentication, pin and token code) for authenticating users in order to gain access to the site. And what I'm seeing now is that all my jQuery posts are returning "405 error".

跨站点请求想到的,很明显,但没有说是怎么回事。所有的jQuery AJAX的职位都使用在了AjaxWebMethods.aspx,这页驻留在该网站的自己的域声明Web方法。

Cross-site requests comes to mind, obviously, but none of that is going on here. All of the jQuery AJAX posts are using web methods that are declared in the AjaxWebMethods.aspx, which page resides in the site's own domain.

在此先感谢您的任何帮助或建议!

Thanks in advance for any help or suggestions!

编辑:

在IE8中使用招给我多一点的信息。错误code,它返回仍然是405,但服务器的错误是更具描述性。服务器错误是用于访问路径的HTTP动词POST/AjaxWebMethods.aspx/UpdNote'是不允许的。

Using Fiddler in IE8 gives me a little more information. The error code that it returns is still 405, but the server error is more descriptive. The server error is "The HTTP verb POST used to access path '/AjaxWebMethods.aspx/UpdNote' is not allowed."

我也尝试改变AJAX请求来获取的类型参数,但我得到了404,而不是(资源无法找到)。

I did try changing the type parameter of the ajax request to GET, but I get a 404 instead (The resource cannot be found).

此外,忘了提,这是通过SSL(虽然我不指望这​​会有所作为)。

Also, forgot to mention that this is over SSL (although I don't expect this would make a difference).

编辑:

经过广泛的测试(和广泛的帮助下计算器的精明的成员),我已经确定405错误,该网站正在使用,并且更具体地被选择为使托管管道模式直接相关的应用程序池应用程序池。

After extensive testing (and extensive help from the astute members of stackoverflow) I've determined that 405 error is directly related to the Application Pool that the website is using, and more specifically to the Managed Pipeline Mode that is selected for the Application Pool.

如果我使用一个应用程序池的目标V4.0(.NET框架)和综合(托管管道模式),然后我的AJAX后工作得很好。但是,如果我使用一个应用程序池的目标V4.0和经典(托管管道模式),然后我得到的405错误。

If I use an Application Pool that targets v4.0 (.NET Framework) and Integrated (Managed Pipeline Mode) then my AJAX post works just fine. But if I use an Application Pool that targets v4.0 and Classic (Managed Pipeline Mode) then I get the 405 error.

所以在这一点上,我还在寻找一个解决这个问题,但我已经能够在家中的问题。

So at this point I'm still looking for a solution to this question, although I've been able to home-in on the problem.

推荐答案

根据这样的:

jQuery的职位,并在Windows身份验证的环境中Web方法既美妙的工作(即 - 用户通过LDAP身份验证)。不过,最近我的网站移动到使用RSA(双因素身份验证,PIN码和令牌code)对于以获得访问该网站的用户进行身份验证的服务器。而我所看到的是,现在我所有的jQuery的帖子正在返回405错误。

The jQuery post and the web method both work wonderful in a Windows Authenticated environment (ie - users are authenticated by LDAP). However, I recently had to move the website to a server that uses RSA (two-factor authentication, pin and token code) for authenticating users in order to gain access to the site. And what I'm seeing now is that all my jQuery posts are returning "405 error".

很显然,错误与服务器配置有关,但要完全肯定的是,如果你能,建立在RSA服务器的新网站的 的,并为此站点禁用RSA认证,尝试浏览你的网站只是为了绝对确保该错误只与RSA认证,丢弃缺少code相关的组件/在新的服务器配置。

It's clear that the error is related with the server configuration, but to be completely sure, if you can, create a new site in the RSA server and for this site disable the RSA authentication, try to browse your site just to be absolutely sure that the error is only related with the RSA authentication, discarding missing code-related components/configuration in the new server

一旦放弃code相关的配置问题,我会鼓励你仔细检查您的RSA配置(这可能会非常棘手)。有一次,我曾在一个项目中,以实现跨服务器一个SSO使用RSA的安全性。 (单点登录),我记得有一个 RSA ISAPI安装在服务器级别过滤器,而这个过滤器是负责读取/设置身份验证Cookie,以验证对Active Directory服务器的每个请求。

Once you have discarded code-related configuration issues, I would encourage you to double check your RSA configuration (which can be tricky). Once I worked in a project using RSA security in order to implement a SSO across servers. (Single Sign On), I remember there was a RSA ISAPI filter installed at the server level, and this filter was in charge to read/set authentication cookies in order to authenticate each request against an Active Directory Server.

由于每个请求是由该过滤器管理和本ISAPI滤波器是在管道的顶部,每个请求都必须按照RSA ISAPI滤波器首先为了进行验证处理

Since each request was managed by this filter and this ISAPI filter was at the top of the pipeline, every request had to be handled by the RSA ISAPI filter first in order to be authenticated

所以,我的建议是仔细检查以便在RSA配置,以检测是否有东西挡住你的AJAX的帖子

So my suggestion is double check the RSA configuration in order to detect if there's something blocking your AJAX posts

我记得RSA配置就像一个魔法盒子,我们没有足够的文件和配置,这是一个PITA。我真诚地希望这不是您的组织的情况下

I remember the RSA configuration was like a black magic box, we didn't have enough documentation and configuring it was a PITA. I sincerely hope this is not the case in your organization

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

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