("NetworkError: 401 Unauthorized) Calling code behind method from JavaScript
("NetworkError: 401 Unauthorized) Calling code behind method from JavaScript
我正在尝试从 JS 调用代码隐藏方法
但它给了我这个错误
NetworkError: 401 Unauthorized
这是方法背后的代码
[System.Web.Services.WebMethod]
public string ExtractToPDF(string FSID)
{
return FSID;
}
这是 JS 函数
function extractFile(FSID) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Update.aspx/ExtractToPDF",
data: "{"+FSID+"}",
dataType: "json",
success: function(data) {
alert(data)
},
error: function(result) {
alert("Error");
}
});
}
这是回复
{
"Message": "An error occurred during the processing of the request",
"StackTrace": "",
"ExceptionType": ""
}
方法背后的代码需要是静态的
简单的解决方案:
[System.Web.Services.WebMethod]
public static string ExtractToPDF(string FSID)
{
return FSID;
}
我正在尝试从 JS 调用代码隐藏方法 但它给了我这个错误
NetworkError: 401 Unauthorized
这是方法背后的代码
[System.Web.Services.WebMethod]
public string ExtractToPDF(string FSID)
{
return FSID;
}
这是 JS 函数
function extractFile(FSID) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Update.aspx/ExtractToPDF",
data: "{"+FSID+"}",
dataType: "json",
success: function(data) {
alert(data)
},
error: function(result) {
alert("Error");
}
});
}
这是回复
{
"Message": "An error occurred during the processing of the request",
"StackTrace": "",
"ExceptionType": ""
}
方法背后的代码需要是静态的
简单的解决方案:
[System.Web.Services.WebMethod]
public static string ExtractToPDF(string FSID)
{
return FSID;
}