0

I'm running my app on shared hosting.

When I run the latest changes on my dev server, everything works fine - When I upload, I see the generic "Error occured but isn't being shown" message.

If I change my web.config to include

CustomErrors mode="off"

then I still see the same error message.

I'm guessing that one of my recent changes is causing an issues when web.config is being parsed.

Is there any way I can retrieve the details of this error? The only ways I'm aware of are Event log and server logs - neither of which I have access to.

Many thanks in advance for any help


Here's the code to save everyone else some time in future. Will format the exception details and mail it. Add a Global.asax if it doesn't exist. then update the Application_Error method.

    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_ADDRESS_HERE@example.com"))
        Dim SMTP As New SmtpClient
        SMTP.Send(Message)

    Catch FatalEx As Exception
        'Write to file, die or re-throw
    End Try
End Sub
Basic
  • 26,321
  • 24
  • 115
  • 201

1 Answers1

1

this is the way.

this. __curious_geek
  • 42,787
  • 22
  • 113
  • 137
  • I'll give it a go but I _believe_ the error is occuring before ASP.Net has initialised completely so am not sure if this will catch it - I'll get back to you shortly – Basic Nov 06 '09 at 20:36
  • Wow, I couldn't have been more wrong. It works like a charm - I've got it emailing me the error details. I'll post an additional answer with some code in case it helps someone in future. – Basic Nov 06 '09 at 22:18
  • My apologies and thanks for the correction - It seems I need others to vote to delete the answer? – Basic Nov 07 '09 at 19:10