自定义错误页面
2009-01-24 10:07
302 查看
在Web.config中:
<customErrors mode ="On" defaultRedirect="~/ErrorCustom.aspx" />
customErrors mode ="On" 服务器和客户端都显示自定义错误页面
customErrors mode ="RemoteOnly" 服务器使用标准的错误页面,客户端显示自定义错误页面
在Global.asax中:
protected void Application_Error(object sender, EventArgs e)
{
if (Context != null && Context.IsCustomErrorEnabled)
{
Server.Transfer("ErrorCustom.ASPX", false);
}
}
在ErrorCustion.ASPX中:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Exception ex = Server.GetLastError().GetBaseException();
Label1.Text = ex.Message;
Server.ClearError();
}
}
<customErrors mode ="On" defaultRedirect="~/ErrorCustom.aspx" />
customErrors mode ="On" 服务器和客户端都显示自定义错误页面
customErrors mode ="RemoteOnly" 服务器使用标准的错误页面,客户端显示自定义错误页面
在Global.asax中:
protected void Application_Error(object sender, EventArgs e)
{
if (Context != null && Context.IsCustomErrorEnabled)
{
Server.Transfer("ErrorCustom.ASPX", false);
}
}
在ErrorCustion.ASPX中:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Exception ex = Server.GetLastError().GetBaseException();
Label1.Text = ex.Message;
Server.ClearError();
}
}
相关文章推荐
- 页面控件自定义错误提示框
- Nginx 之自定义错误页面
- asp.net自定义错误处理页面的几种方法
- 添加空白页面后继承自定义类提示错误:声明一定不能指定不同的基类
- JSP JAVA 自定义 错误页面(404,505,500)
- spring mvc配置自定义错误404,500页面
- 在Tomcat中配置404自定义错误页面全解
- java后台自定义错误页面
- Ruby On Rails 自定义错误页面的显示信息 指定显示页面
- JSP应用程序(自定义错误页面)
- asp.net自定义错误页面及出错分析
- 在Tomcat中配置404自定义错误页面
- Android WebView自定义错误页面笔记
- 新西兰程序员 ASP.NET网站中设置404自定义错误页面
- django的403/404/500错误自定义页面的配置
- 【MVC】MVC 4 自定义错误页面
- Web项目自定义错误页面
- jsp自定义错误页面
- 自定义 404 与 500 错误页面,URL 地址不会重定向(一)
- web.xml中设置统一的自定义错误页面