我很难弄清楚为什么我的web服务在仅在生产环境中从asp.net应用程序调用时不能正常工作。
我能够在本地运行我的asp.net应用程序,调用web服务(在生产环境中)并正确完成。
我可以修改web.config以允许我在生产web服务上使用测试表单,并且它可以正确调用。
我在一个共享的dll中调用web服务,并且我已经检查了我是否真的得到了更新的dll。
ExceptionServices
我的共享dll有一个类
ErrorHandler
调用(此时,是一个测试方法)
TestEmail(string to)
我所做的就是给我发一封电子邮件。
就像我说的,当在本地运行我的应用程序时,它调用生产web服务,一切都很好。
敲击键盘
)...
[WebMethod]
public void TestEmail(string to)
{
MailMessage mm = new MailMessage("no-reply@mydomain.com", to, "test", "body here");
SmtpClient client = new SmtpClient("localhost"); // already tried tweaking smtp server, and all my options work when I use the test form
client.Send(mm);
}
共享dll中的ErrorHandler类
public class ErrorHandler
{
public static void ThrowError(Exception ex, string sitename, string ip, string username)
{
//if (ip != "127.0.0.1") // exclude local errors when developing
{
EILib.ExceptionServices.EIExceptionHandler eh = new EILib.ExceptionServices.EIExceptionHandler();
eh.TestEmail("senloe@....com");
}
}
}
最后是我的global.asax,一切从这里开始:
protected void Application_Error(object sender, EventArgs e)
{
//Get the Error.
System.Exception anError = Server.GetLastError();
EILib.ErrorHandler.ThrowError(anError, "mydomain.com", EILib.Utilities.GetUserHostAddress(Request), User.Identity.Name);
....
}