这个问题与其说是出于好奇,不如说是出于好奇。在这个场景中,我设置了一些代码,让我知道我的ASP.Net内部网门户中是否有任何错误。这是绝对没有问题的,它更多的是积极主动,而不是任何其他,以防万一。
长话短说,我在Global.asax.cs中添加了这段代码
protected void Application_Error(object sender, EventArgs e) {
try {
Exception ex = Server.GetLastError();
if (ex != null) {
MailMessage message = new MailMessage("a@company.com.au", "me@company.com.au");
message.Subject = @"Error";
message.Body = string.Format(@"<html><body>Unhandled error on: {0} <br/> {1} <br/> {2}",ex.Source.ToString(),ex.Message,ex.ToString ());
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("server.company.com.au");
client.Send(message);
message.Dispose();
client.Dispose();
}
} catch (Exception) { }
}我一直在邮件里收到这条错误信息:
未处理错误: System.Web文件不存在。System.Web.HttpException (0x80004005):文件不存在。在System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo,String physicalPath,HttpResponse response)在System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext上下文中,String overrideVirtualPath)在System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext上下文中,AsyncCallback回调,Object state)在System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤( System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,布尔& completedSynchronously)
我很困惑。我不知道这个错误是从哪里来的,我还在努力寻找它。它没有以任何方式影响网站的任何方面。我相信这个错误会出现在前面,因为我所做的就是添加上面的代码。我使用的是.Net Far4框架。
有人知道这是什么吗?
发布于 2014-02-19 00:46:05
对于您所有的错误记录,我强烈推荐ELMAH。易于实现,当某些错误发生时,它可以发送电子邮件给您。
此外,还将节省您的时间来创建一个本土的解决方案。
发布于 2014-02-19 00:58:42
请检查母版页引用的丢失的文件或图像。若要捕获错误,请将以下错误处理程序添加到Global.asax中
protected void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex.Message == "File does not exist.")
{
throw new Exception(string.Format("{0} {1}", ex.Message, HttpContext.Current.Request.Url.ToString()), ex);
}
}有一段时间,这个问题与缺少文件favicon.ico有关。
https://stackoverflow.com/questions/21868659
复制相似问题