JQuery 到 asmx 在 Windows 2008 R2 SP1 上失败
自从安装 SP1 以来,我们在从 JQuery 客户端代码调用 asmx 页面时遇到了问题。
IIS 将 JQuery post 调用指向他的默认 404 页面。
我们对环境进行了角色恢复,断言此问题是由 SP1 引起的,并且测试证实了这一点。
等待修复@MS
使用的技术:
ASP.Net 4.0 - jQuery - IIS 7.5 - Windows 2008 R2 SP1
--Bart
代码示例调用(前端):
// 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');
}
});
}
代码后端:
[ScriptService]
public class ProductRating : System.Web.Services.WebService
{
[WebMethod(EnableSession=true)]
public RateProductResponse RateProduct(Guid uniqueId, Guid productId, int points, bool showOwnScore)
{
//Implementation
}
快照1:使用 SP1: http://img812.imageshack.us/i/capture2r.png/
快照2:没有 SP1: http://img190.imageshack.us/i/capture1qx.png/
Since the installation of SP1 we are facing problems in calling asmx pages from JQuery client code.
IIS is pointing the JQuery post call to his default 404 page.
We did a roleback of our environment to assert this issue is caused by SP1 and tests confirm it.
Waiting for a fix @MS
Technologies used:
ASP.Net 4.0 -
JQuery -
IIS 7.5 -
Windows 2008 R2 SP1
--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/
Snapshot2 : Without SP1:
http://img190.imageshack.us/i/capture1qx.png/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可以通过在 web.config 中添加以下内容来实现此功能,
我看到另一个网站建议清除处理程序,但这使一切变得更糟。通过此更新,我能够再次调用我的网络服务。
I was able to get this working with the following addition to my 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.Config 文件:
将其复制到提供受影响脚本的目录中,然后重新启动 Web 服务器。
这些行将覆盖您首选的 HttpHandler 并将其设置为使用默认处理程序。
祝你好运!
I had the same problem.
Create a Web.Config file containing the following lines:
Copy this into the directory(s) where you serve out your affected scripts, and restart your web server.
These lines will override your preferred HttpHandlers and set it to use the default handlers instead.
Good luck!
从你的屏幕截图来看,这看起来很像 URL 重写问题。您的网站在 IIS 级别是否有任何过度贪婪的 URL 重写规则,可能是 302 重定向
/Handlers/ProductRating.asmx/RateProduct
?如果您确实有重写规则,您可以尝试暂时禁用它们,看看是否可以解决 ASMX 问题?
Judging by your screenshots, that seems an awful lot like a URL rewriting issue. Does your site have any overly-greedy URL rewrite rules at the IIS level that could be 302 redirecting
/Handlers/ProductRating.asmx/RateProduct
?If you do have rewrite rules, can you try disabling them temporarily to see if that fixes the ASMX issue?