zoukankan      html  css  js  c++  java
  • 在Asp.net中自定义异常页面

    按异常处理优先级排序
      (0)在Global.asax的Application_Error添加代码
        protected void Application_Error(Object sender, EventArgs e)
        {
            Context.ClearError();
            Response.Write("Error");
            Response.Redirect("errorpage.htm");
        }

      (1)后台代码中的WebForm1_Error
         aspx页面的属性中UI.Page的Error事件中添加异常处理代码
         private void WebForm1_Error(object sender, System.EventArgs e)
         {
            Exception ex=Server.GetLastError();
            Session["error"]=ex.Message;
            Server.ClearError();
            Response.Redirect("error.aspx");
         }
      (2)在html代码中加入ErrorPage
         ErrorPage="http://www.21cn.com"
      (3)在Web.config中添加异常处理的页面
        <customErrors mode="On" defaultRedirect="error.aspx">
        <error statusCode="401" redirect="error.aspx"/>
        <error statusCode="404" redirect="http://www.sina.com.cn"/>
        </customErrors>
      (4)在IIS中设置异常处理页
  • 相关阅读:
    还需要做恰当的解读,此时你可能需要一些书:
    创业公司的架构演进史
    任务调度平台Cuckoo-Schedule
    ORACLE中死锁
    Action的模型绑定
    三次握手、四次握手、backlog
    Django框架
    扩展BootstrapTable的treegrid功能
    Identity Service
    Linux权限
  • 原文地址:https://www.cnblogs.com/King0502/p/2019367.html
Copyright © 2011-2022 走看看