简体   繁体   English

在Windows 2008 R2 SP1上,asmx的JQuery失败

[英]JQuery to asmx fails on Windows 2008 R2 SP1

Since the installation of SP1 we are facing problems in calling asmx pages from JQuery client code. 自从安装SP1以来,我们在从JQuery客户端代码调用asmx页面时遇到了问题。

IIS is pointing the JQuery post call to his default 404 page. IIS将JQuery post调用指向其默认的404页面。

We did a roleback of our environment to assert this issue is caused by SP1 and tests confirm it. 我们做了我们环境的角色来断言这个问题是由SP1引起的,测试证实了这一点。

Waiting for a fix @MS 等待修复@MS

Technologies used: 使用的技术:

ASP.Net 4.0 - JQuery - IIS 7.5 - Windows 2008 R2 SP1 ASP.Net 4.0 - JQuery - IIS 7.5 - Windows 2008 R2 SP1

--Bart --Bart

Code Sample calling (front-end): 代码示例调用(前端):

  // Code to load vars...
  $.ajax({

              type: "POST",
              url: "/Handlers/ProductRating.asmx/RateProduct",
              data: "{'uniqueId':'" + uniqueId + "','productId':'" + productId + "','points':" + points.toString() + ",'showOwnScore':" + showOwnScore.toString() + "}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(response) {
                   alert('success');
              },
              failure: function(msg) {
                alert('something went wrong');
              }
            });
        }

Code back-end: 代码后端:

 [ScriptService]
public class ProductRating : System.Web.Services.WebService
{

    [WebMethod(EnableSession=true)]
    public RateProductResponse RateProduct(Guid uniqueId, Guid productId, int points, bool showOwnScore)
    {
       //Implementation
    }

Snapshot1 : With SP1: http://img812.imageshack.us/i/capture2r.png/ Snapshot1:SP1: http//img812.imageshack.us/i/capture2r.png/

Snapshot2 : Without SP1: http://img190.imageshack.us/i/capture1qx.png/ Snapshot2:没有SP1: http//img190.imageshack.us/i/capture1qx.png/

I was able to get this working with the following addition to my web.config 我能够通过以下添加到我的web.config来实现这一点

I saw another site that suggested clearing the handlers, but that made everything way worse. 我看到另一个网站建议清理处理程序,但这使一切变得更糟。 With this update, I was able to call my web services once again. 通过此更新,我可以再次调用我的Web服务。

<system.webServer>
    <handlers>
        <add name="AsmxRoutingHandler" verb="*" path="*.asmx"  type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
</system.webServer>

I had the same problem. 我有同样的问题。

Create a Web.Config file containing the following lines: 创建包含以下行的Web.Config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <location path="." inheritInChildApplications="false">
        <system.web>
            <httpHandlers>
                <clear />
                <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add path="*" verb="GET,HEAD,POST" type="System.Web.DefaultHttpHandler" validate="True" />
            </httpHandlers>
        </system.web>
    </location>
</configuration>

Copy this into the directory(s) where you serve out your affected scripts, and restart your web server. 将其复制到您提供受影响脚本的目录中,然后重新启动Web服务器。

These lines will override your preferred HttpHandlers and set it to use the default handlers instead. 这些行将覆盖您首选的HttpHandlers,并将其设置为使用默认处理程序。

Good luck! 祝好运!

Judging by your screenshots, that seems an awful lot like a URL rewriting issue. 从您的屏幕截图来看,这看起来很像URL重写问题。 Does your site have any overly-greedy URL rewrite rules at the IIS level that could be 302 redirecting /Handlers/ProductRating.asmx/RateProduct ? 您的站点是否在IIS级别有任何过于贪婪的URL重写规则,可能是302重定向/Handlers/ProductRating.asmx/RateProduct

If you do have rewrite rules, can you try disabling them temporarily to see if that fixes the ASMX issue? 如果您确实有重写规则,是否可以尝试暂时禁用它们以查看是否修复了ASMX问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM