Normally I just redirect to a custom error page in on the Application_Error event, but I have a specific error for which I'd like to display an alert message while the user is still on the page which triggers the error. How can I make this happen?
I'm open to a modalpopup or any other type of error message, I just want to ensure the user stays on the page where they encounter the error.
Thank for any ideas.
This is in reference to this thread: http://stackoverflow.com/questions/2464341/a-potentially-dangerous-request-form-value-was-detected-dealing-with-these-error
Here is the code I'm currently using:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) 'Code that runs when an unhandled error occurs Try Dim err As Exception = Server.GetLastError If err.Message IsNot Nothing Then If err.Message = "The client disconnected." Then Dim LogError As New LogError(Server.GetLastError, Session, Request) LogError.LogError() Response.Redirect("~/TimeoutPage.aspx?id=2") ElseIf err.Message.Contains("dangerous Request.Form value") Then 'Response.Redirect("~/MyInputErrorPage.aspx") 'Instead the above redirect, I'd like to show the user an alertbox or something similar to explain the error to them Else Dim LogError As New LogError(Server.GetLastError, Session, Request) LogError.LogError() Response.Redirect("~/MyErrorPage.aspx") End If End If Catch ex As Exception End Try