自从安装 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/ http://img812.imageshack.us/i/capture2r.png/
快照2:不带SP1:http://img190.imageshack.us/i/capture1qx.png/ http://img190.imageshack.us/i/capture1qx.png/