views:

116

answers:

1

Hi,

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 protected]"))
  Dim SMTP As New SmtpClient
  SMTP.Send(Message)

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

this is the way.

this. __curious_geek
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
Basiclife
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.
Basiclife
My apologies and thanks for the correction - It seems I need others to vote to delete the answer?
Basiclife