Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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
share|improve this question

1 Answer

up vote 1 down vote accepted

this is the way.

share|improve this answer
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 6 '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 6 '09 at 22:18
My apologies and thanks for the correction - It seems I need others to vote to delete the answer? – Basic Nov 7 '09 at 19:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.