Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication_Error ignored?
    primarykey
    data
    text
    <p>I've put the following code in global.asax</p> <pre><code>&lt;%@ Application Language="VB" %&gt; &lt;script runat="server"&gt; Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code, der beim Starten der Anwendung ausgeführt wird. End Sub Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) ' Code, der beim Beenden der Anwendung ausgeführt wird. End Sub ' HelpLink Gets or sets a link to the help file associated with this exception. ' InnerException Gets the Exception instance that caused the current exception. ' Message Gets a message that describes the current exception. ' Source Gets or sets the name of the application or the object that causes the error. ' StackTrace Gets a string representation of the frames on the call stack at the time the current exception was thrown. ' TargetSite Gets the method that throws the current exception. ' http://www.developer.com/net/asp/article.php/961301/Global-Exception-Handling-with-ASPNET.htm Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Code, der bei einem nicht behandelten Fehler ausgeführt wird. 'get reference to the source of the exception chain Dim ex As Exception = Server.GetLastError().GetBaseException() 'log the details of the exception and page state to the 'Windows 2000 Event Log 'System.Diagnostics.EventLog.WriteEntry("source", "MESSAGE: " + ex.Message + "\nSOURCE: " + ex.Source + "\nFORM: " + _ 'HttpContext.Current.Request.Form.ToString() + "\nQUERYSTRING: " + HttpContext.Current.Request.QueryString.ToString() + _ '"\nTARGETSITE: " + ex.TargetSite.ToString + "\nSTACKTRACE: " + ex.StackTrace, System.Diagnostics.EventLogEntryType.Error) Response.Redirect("GeneralError.aspx", False) 'Response.Redirect("GeneralError.aspx") 'Insert optional email notification here... ''this is what we are sending 'Dim post_data As String = "MESSAGE: " + ex.Message + "\nSOURCE: " + ex.Source + "\nFORM: " + _ 'HttpContext.Current.Request.Form.ToString() + "\nQUERYSTRING: " + HttpContext.Current.Request.QueryString.ToString() + _ '"\nTARGETSITE: " + ex.TargetSite.ToString + "\nSTACKTRACE: " + ex.StackTrace 'post_data = HttpContext.Current.Server.UrlEncode(post_data) '' this is where we will send it 'Dim uri As String = "http://localhost/cor_raumplaner/GlobalError.aspx" '' create a request 'Dim request As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(uri), System.Net.HttpWebRequest) 'request.KeepAlive = False 'request.ProtocolVersion = System.Net.HttpVersion.Version10 'request.Method = "POST" '' turn our request string into a byte stream 'Dim postBytes As Byte() = Encoding.ASCII.GetBytes(post_data) '' this is important - make sure you specify type this way 'request.ContentType = "application/x-www-form-urlencoded" 'request.ContentLength = postBytes.Length 'Dim requestStream As System.IO.Stream = request.GetRequestStream() '' now send it 'requestStream.Write(postBytes, 0, postBytes.Length) 'requestStream.Close() '' grab te response and print it out to the console along with the status code 'Dim response1 As System.Net.HttpWebResponse = DirectCast(request.GetResponse(), System.Net.HttpWebResponse) 'Response.Write(New System.IO.StreamReader(response1.GetResponseStream()).ReadToEnd()) 'Response.Write(response1.StatusCode) End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code, der beim Starten einer neuen Sitzung ausgeführt wird. End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ' Code, der am Ende einer Sitzung ausgeführt wird. ' Hinweis: Das Session_End-Ereignis wird nur ausgelöst, wenn der sessionstate-Modus ' in der Datei "Web.config" auf InProc festgelegt wird. Wenn der Sitzungsmodus auf StateServer ' oder SQLServer festgelegt wird, wird das Ereignis nicht ausgelöst. End Sub &lt;/script&gt; </code></pre> <p>Then i've added a new page, and made it generate an error, like this:</p> <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim mylanguage As String = Session("Language") Dim iLength As Integer = mylanguage.Length End Sub </code></pre> <p>Now, the problem is seems to be that the application error handler in global.asax doesn't get called, instead I receive a standard exception: "Object reference not set to an instance of an object"</p> <p>Why ? Shouldn't it call the error handler and redirect to the GeneralError.aspx page ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload