Name
ErrorPage
Synopsis
String = Page.ErrorPage Page.ErrorPage = String
Returns or sets the name of the page to redirect to in the event of an unhandled page exception.
Parameters
-
String
A String value that indicates the name of the page to redirect to in the event of an unhandled page exception.
Example
The example below changes the ErrorPage property and shows that executed page when an unhandled exception occurs in the page:
Sub Page_Load( ) Page.ErrorPage = "ErrorPage_Handler.aspx" Dim x, y, overflow As Integer x = 1 y = 0 overflow = x/y 'This code will not be executed Message.Text = "Error Page is " & Page.ErrorPage & "." End Sub
The Page_Load for ErrorPage_Handler.aspx is shown below:
Sub Page_Load( ) Message.Text = "We're sorry. An error occurred during the" & _ " processing of your request. Please try again later." End Sub
Notes
The ErrorPage property can also be specified using the
ErrorPage
attribute of the @ Page
directive.
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.