zoukankan      html  css  js  c++  java
  • TIPS: Error handling in ASP.Net 2.0

    TIPS: Error handling in ASP.Net 2.0

     

    Posted by: Rickie Lee http://rickie.cnblogs.com

    In order to avoiding generating an ugly error message to end users, we can handle it in two ways.

    1. Add a custom error page to web site. When an unhandled error occurs, a user-friendly web page will come and ask the users to come back later.

     

    2. Add a Global.asax file into web site, where you can add log this kind of errors.

     

    Follows the following steps to take care:

    1. Modify Application_Error method in Global.asax file like this:
        void Application_Error(object sender, EventArgs e)

        {

            // Code that runs when an unhandled error occurs

            // Log all unhandled errors

           

    }

     

    2. Config web.config file, add a new child of the <system.web> element:
        <customErrors mode="RemoteOnly" defaultRedirect="BasePage/Error.aspx" />

    3. Add a user-friendly error-handling web page, which appears when an unhanlded error happens.

    Add some conent like this:

    Your request generated an internal error!

    We apologize for the inconvenience! The error has been reported.

    Thanks for accessing http://rickie.cnblogs.com web site!

     

     

  • 相关阅读:
    FPGA在其他领域的应用(一)
    FPGA IN 消费电子
    FPGA IN 金融领域
    FPGA与PCI-E
    FPGA与数字信号处理
    FPGA与数字图像处理技术
    FPGA与安防领域
    FPGA在电平接口领域的应用
    FPGA与Deep Learning
    FPGA多时钟处理应用
  • 原文地址:https://www.cnblogs.com/rickie/p/364114.html
Copyright © 2011-2022 走看看