【发布时间】:2011-03-19 06:26:11
【问题描述】:
我无法弄清楚为什么我的 Web 服务仅在生产环境中从我的 asp.net 应用程序调用时无法正常工作。
我能够在本地运行我的 asp.net 应用程序,调用 Web 服务(在生产中)并且它正确完成。
我能够修改 web.config 以允许我在生产 Web 服务上使用测试表单并且它可以正确调用。
我在一个共享的 dll 中调用网络服务,并且我已经检查我是否真的得到了更新的 dll。
这是一个非常基本的网络服务,用于记录我们网站上未在其他地方处理的任何异常。我正在向它添加额外的参数,并将它移动到另一个项目,以便它与我们的更多 Web 服务组合在一起。它在它自己的 asmx 文件中,名为 ExceptionServices
我的共享 dll 有一个类 ErrorHandler,它调用(此时是一个测试方法)TestEmail(string to),它所做的只是给我发一封电子邮件。
就像我说的,在本地运行我的应用程序时,它会调用生产网络服务,一切都很好。
我在托管环境中运行,无法安装远程调试工具,因此我无法单步执行生产代码(除非有人知道任何技巧)。
这似乎应该可以工作(敲键盘)...
这是我的基本网络方法:
[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);
....
}
【问题讨论】:
-
它会给出任何错误信息吗?事件日志中有任何内容吗?或者这是一个完全无声的失败?
-
没有我能找到的错误。该解决方案托管在 Rackspace,因此我认为我无法以任何形式访问事件日志。我在 Web 服务上启用了跟踪。我可以看到来自 localhost 的调用,但看不到生产,因此似乎没有调用 Web 服务。所有路径看起来都正确,我在我的 Web 应用程序的跟踪输出中看不到任何内容。
-
如果所有其他方法都失败了,将调试语句写入文本文件总是完全不优雅的解决方案。
标签: c# asp.net web-services debugging exception-handling