通常,我只是重定向到Application_Error事件中的自定义错误页面,但我有一个特定的错误,我希望显示一条警报消息用户仍然在触发错误的页面上。我怎样才能做到这一点?显示来自Global.asax的警报消息框(在Application_Error事件中)
我打开modalpopup或任何其他类型的错误消息,我只是想确保用户停留在他们遇到错误的页面上。
感谢您的任何想法。
下面是我目前使用的代码:发生错误
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
您可以定义您需要此功能的特定情况吗?一旦用户点击某些内容并触发请求,它们就不再是“在页面上”了。 你为什么不给页面本身添加错误处理呢? – Ocelot20 2010-04-12 14:35:49
有大量的页面可能会触发此错误,我不想更新所有这些。这就是为什么我试图在Global.asax中处理此问题请参阅修订后的问题。 ..这是关于捕捉错误,当用户输入像< and >字符等潜在危险字符时......并且我不想在每个页面/输入控件上对这些字符进行验证。 – Albert 2010-04-12 15:47:57