在共享主机上调试ASP.Net web.config问题

问题描述:

我在共享主机上运行我的应用程序。在共享主机上调试ASP.Net web.config问题

当我在我的开发服务器上运行最新的更改时,一切正常 - 当我上传时,我看到通用的“错误发生但未显示”消息。

如果我改变我的web.config包括

CustomErrors mode="off" 

话,我仍看到相同的错误消息。

我猜我最近的一个变化是在解析web.config时导致问题。

有没有什么办法可以检索到这个错误的细节?我知道的唯一方法是事件日志和服务器日志 - 我都无法访问它们。

提前许多感谢所有帮助


下面的代码保存其他人在未来的一段时间。将格式化异常详情并发送邮件。如果不存在,请添加Global.asax。然后更新Application_Error方法。

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) 
    ' Code that runs when an unhandled error occurs 
    Dim ex As Exception = Server.GetLastError().GetBaseException() 
    Dim ErrMsg As New Text.StringBuilder 

    While ex IsNot Nothing 
     ErrMsg.AppendLine(String.Format("Message : {0}", ex.Message)) 
     ErrMsg.AppendLine(String.Format("Source : {0}", ex.Source)) 
     ErrMsg.AppendLine(String.Format("Target : {0}", ex.TargetSite.ToString)) 
     ErrMsg.AppendLine("Stack: ") 
     ErrMsg.AppendLine(ex.StackTrace) 

     If ex.InnerException IsNot Nothing Then 
      ex = ex.InnerException 
      ErrMsg.AppendLine(">> Inner Exception >>>>>>>>>>>>>>>>>>>>>") 
     Else 
      ex = Nothing 
     End If 

    End While 

    Try 
     Dim Message As New System.Net.Mail.MailMessage 
     Message.Body = ErrMsg.ToString 

     Message.Subject = "MPW Error" 
     Message.To.Add(New MailAddress("[email protected]")) 
     Dim SMTP As New SmtpClient 
     SMTP.Send(Message) 

    Catch FatalEx As Exception 
     'Write to file, die or re-throw 
    End Try 
End Sub 

this就是这样。

+0

我会给它一个去,但我_believe_错误发生之前ASP.Net完全初始化,所以我不知道这是否会抓住它 - 我会尽快回复您 – Basic 2009-11-06 20:36:03

+0

哇,我不能更加错误。它的作用就像一个魅力 - 我已经通过电子邮件向我发送了错误细节。我会用一些代码发布一个额外的答案,以防将来帮助某人。 – Basic 2009-11-06 22:18:37

+0

我的道歉和感谢纠正 - 似乎我需要其他人投票删除答案? – Basic 2009-11-07 19:10:17