处理请求时出现错误
本文关键字:错误 请求 处理 | 更新日期: 2023-09-27 18:14:38
我得到这个错误"有一个错误处理请求"在UAT环境。在我的本地,代码似乎工作得很好。
这一行实用程序。直接写入数据库。无论这一行是否失败,我都应该仍然能够接收到来自服务器的消息,因为它被正确处理了。
但是由于我没有收到服务器的任何响应,这意味着我的webmethod不可达。
考虑到下面的代码工作,有什么我需要设置在网络。配置使此工作?或者任何我可以开始检查IIS的地方,给我一些线索?
谢谢。
$('#lnkTest').click(function () {
alert('Click event is firing!');
$.ajax({
type: "POST",
url: "/_layouts/ServiceForm.aspx/TestService",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (response) {
if (response.d && response.d.length > 0) {
alert(response.d);
}
},
error: function (xhr, err) {
alert('responseText:' + xhr.responseText);
}
});
});
这是我的c# web方法
[WebMethod]
public static string TestService()
{
string strMessage = string.Empty;
try
{
strMessage = "The service is running.";
Utility.WriteLogEvent("TestService", strMessage);
}
catch (Exception ex)
{
strMessage = "TestService fail.";
}
return strMessage;
}
对于在调用带参数的WebMethod时可能遇到相同错误的其他人
确保没有任何参数为空,因为这也会在没有适当原因的情况下抛出相同的错误。提供一种解决方案,以防止将空参数传递给客户端上的方法。也许是if statement
问题已经解决。这是由于在应用程序服务器中部署了一个dll,它被安装的防病毒程序阻止了。