【发布时间】:2014-11-11 07:05:26
【问题描述】:
我正在尝试使用网络服务方法。我还在我的应用程序中使用 url 重写。
我的 ajax jquery 调用如下
$.ajax({
type: "POST",
url: "dataone.asmx/lastName",
data: JSON.stringify({ "firstname": $("#el").val(),"lastname":"Ali" }),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: false,
error: function (errorThrown) {
console.log(errorThrown + " " + errorThrown);
alert(errorThrown.responseText + "what's wrong?" + " " + errorThrown);
},
success: function (msg) {
console.log(msg.d);
alert(msg.d);
return false;
// Do something interesting here.
}
});
我的网络方法正在跟踪
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]//, ResponseFormat = ResponseFormat.Json
public string lastName(string firstname,string lastname)
{
return firstname == "fawad" ? "ali" : "first name incorrect"+lastname;
}
我的友好网址是
<a href="edmonton/clickme">click</a>
在我的 global.asax 中,我正在按照以下方式进行 url 重写
HttpContext.Current.RewritePath(originalPath.Replace("edmonton/clickme", @"Default.aspx"));
但是我的网络方法没有被调用。当我删除 url 重写我的 ajax 调用开始工作
如果你们有任何想法可能是什么问题,请在下面的答案中发布。
谢谢
【问题讨论】:
标签: jquery asp.net .net ajax url-rewriting