Error page not showing
-
I have an error page set up and when an error occurs the page is not shown. From my webconfig file:
From my Global aspx file:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
' gets the error occured
Dim ex As Exception = Server.GetLastError().GetBaseException()
Try
' checks if the event source is registered
If Not System.Diagnostics.EventLog.SourceExists(".NET Runtime") Then
System.Diagnostics.EventLog.CreateEventSource(".NET Runtime", "Application")
End If'log the details of the error occured Dim log As New System.Diagnostics.EventLog() log.Source = ".NET Runtime" log.WriteEntry(\[String\].Format(vbCr & vbLf & vbCr & vbLf & "Application Error" & vbCr & vbLf & vbCr & vbLf + "MESSAGE: {0}" & vbCr & vbLf + "SOURCE: {1}" & vbCr & vbLf + "FORM: {2}" & vbCr & vbLf + "QUERYSTRING: {3}" & vbCr & vbLf + "TARGETSITE: {4}" & vbCr & vbLf + "STACKTRACE: {5}" & vbCr & vbLf, ex.Message, ex.Source, Request.Form.ToString(), Request.QueryString.ToString(), ex.TargetSite, \_ ex.StackTrace), System.Diagnostics.EventLogEntryType.\[Error\]) Server.ClearError() Catch ' in case of exception occured in log Server.ClearError() End Try Server.ClearError() Response.Redirect(String.Format("Error.aspx?aspxerrorpath={0}", Request.Url.PathAndQuery))
End Sub
What I end up seeing is the master page and the URL shows / Error.aspx, but the error page is not shown with it.
-
I have an error page set up and when an error occurs the page is not shown. From my webconfig file:
From my Global aspx file:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
' gets the error occured
Dim ex As Exception = Server.GetLastError().GetBaseException()
Try
' checks if the event source is registered
If Not System.Diagnostics.EventLog.SourceExists(".NET Runtime") Then
System.Diagnostics.EventLog.CreateEventSource(".NET Runtime", "Application")
End If'log the details of the error occured Dim log As New System.Diagnostics.EventLog() log.Source = ".NET Runtime" log.WriteEntry(\[String\].Format(vbCr & vbLf & vbCr & vbLf & "Application Error" & vbCr & vbLf & vbCr & vbLf + "MESSAGE: {0}" & vbCr & vbLf + "SOURCE: {1}" & vbCr & vbLf + "FORM: {2}" & vbCr & vbLf + "QUERYSTRING: {3}" & vbCr & vbLf + "TARGETSITE: {4}" & vbCr & vbLf + "STACKTRACE: {5}" & vbCr & vbLf, ex.Message, ex.Source, Request.Form.ToString(), Request.QueryString.ToString(), ex.TargetSite, \_ ex.StackTrace), System.Diagnostics.EventLogEntryType.\[Error\]) Server.ClearError() Catch ' in case of exception occured in log Server.ClearError() End Try Server.ClearError() Response.Redirect(String.Format("Error.aspx?aspxerrorpath={0}", Request.Url.PathAndQuery))
End Sub
What I end up seeing is the master page and the URL shows / Error.aspx, but the error page is not shown with it.
It seems that everything is fine but the address of Error.aspx is wrong as you say 'master page and the URL shows / Error.aspx'. I guess you must work on the last line:
Response.Redirect(String.Format("Error.aspx?aspxerrorpath={0}", Request.Url.PathAndQuery))
maybe you must replace it with "~/Error.aspx..."