S
slolife
What I am trying to do is handle the HttpRequestValidationException
with code, but only on pages that are equipped to handle it with
special customvalidators, controls, etc.. But what I cannot seem to
find is where to put some code in my derived page that sets a property
in the base page class that tells the base Page_Error to deal with
HttpRequestValidationException.
See the code below.
Here's my base page:
Public Class BasePage
Inherits System.Web.UI.Page
Protected m_CatchHttpRequestValidationException As Boolean
Private Sub Page_Error(s Object, e As EventArgs) Handles
MyBase.Error
If Me.m_CatchHttpRequestValidationException Then
If Server.GetLastError.GetType() Is
GetType(HttpRequestValidationException) Then
HttpContext.Current.Items("HttpRequestValidationException") = True
Server.ClearError()
End If
End If
End Sub
End Class
Here's my derived page:
Partial Class TestPage
Inherits BasePage
Private Sub Page_PreInit(s As Object, e As EventArgs) Handles
MyBase.PreInit
Me.m_CatchHttpRequestValidationException = True
End Sub
Private Sub Page_Init(s As Object, e As EventArgs) Handles
MyBase.Init
Me.m_CatchHttpRequestValidationException = True
End Sub
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles MyBase.Load
Me.m_CatchHttpRequestValidationException = True
End Sub
End Class
Anyone know where to put page code to run before Page_Error occurs and
is called?
Thanks
Chris
with code, but only on pages that are equipped to handle it with
special customvalidators, controls, etc.. But what I cannot seem to
find is where to put some code in my derived page that sets a property
in the base page class that tells the base Page_Error to deal with
HttpRequestValidationException.
See the code below.
Here's my base page:
Public Class BasePage
Inherits System.Web.UI.Page
Protected m_CatchHttpRequestValidationException As Boolean
Private Sub Page_Error(s Object, e As EventArgs) Handles
MyBase.Error
If Me.m_CatchHttpRequestValidationException Then
If Server.GetLastError.GetType() Is
GetType(HttpRequestValidationException) Then
HttpContext.Current.Items("HttpRequestValidationException") = True
Server.ClearError()
End If
End If
End Sub
End Class
Here's my derived page:
Partial Class TestPage
Inherits BasePage
Private Sub Page_PreInit(s As Object, e As EventArgs) Handles
MyBase.PreInit
Me.m_CatchHttpRequestValidationException = True
End Sub
Private Sub Page_Init(s As Object, e As EventArgs) Handles
MyBase.Init
Me.m_CatchHttpRequestValidationException = True
End Sub
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles MyBase.Load
Me.m_CatchHttpRequestValidationException = True
End Sub
End Class
Anyone know where to put page code to run before Page_Error occurs and
is called?
Thanks
Chris