Code reading summary of the Fitch and Mather 7.0

Source: Internet
Author: User

How to asp.net the error prompt page when an exception or error occurs

How do we handle the error message page when an exception or error occurs in asp.net?

I have summed up the following ways:

I: Using the method Response.Redirect ()

Look at the following 2 pieces of code:

1.

When an exception occurs in the page admin.aspx

Try
{//
program logic
}
catch (OverflowException)
{//The exception that is
thrown when an arithmetic operation, type conversion, or conversion operation in the selected context causes an overflow
/ /For example: MinValue or greater than int maxvalue, exception, go to error page
Response.Redirect ("errorpage.aspx", True);
}

2.

In the open source project asp.net startkit timetracker

A logical error occurred in the page userlist.aspx

if (Ttsecurity.isinrole (ttuser.userroleadministrator) = = False)
{
//The role of the visitor is not "Administrator", the Prompt Role error page
Response.Redirect ("Accessdenied.aspx?") Index=-1 ", True);
}

Ii. using the configuration file Web.config

We first set

<customerrors
mode= "on"
defaultredirect= "errorpage.aspx"
/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.