.net跳到指定错误页面兵显示详细的错误信息
来源:互联网 发布:淘宝网女童公主裙 编辑:程序博客网 时间:2024/05/17 03:27
1.需要在 Global.asax页面中的Application_Error事件中添加处理方法
void Application_Error(object sender, EventArgs e)
{
//在出现未处理的错误时运行的代码
HttpContext ctx = HttpContext.Current;
Exception exception = ctx.Server.GetLastError();
string directUrl = "DefaultError.html?error=";
if (exception != null)
{
string errorInfo = "URL:" + ctx.Request.RawUrl.ToString() + "Source:" + exception.Source
+ "Message:<strong>" + exception.Message + "</strong>";
errorInfo = "错误信息为:<strong>" + exception.InnerException.Message + "</strong>";
//if (exception is HttpException)
//{
// HttpException ex = exception as HttpException;
// int httpCode = ex.GetHttpCode();
// errorInfo = "Code:<strong>" + httpCode.ToString() + "</strong>" + errorInfo;
string url=ctx.Request.Url.ToString();
directUrl = url.Substring(0, url.ToString().IndexOf("/Web/") + 5) + directUrl + errorInfo;
directUrl += "&referurl=" + ctx.Request.Url.ToString();
//if (httpCode == 404)
//{
// directUrl = "~/DefaultError.html?error=" + errorInfo;
//}
//if (httpCode == 403 || httpCode == 402 || httpCode == 401)
//{
// directUrl = "~/DefaultError.html?error=" + errorInfo;
//}
//}
ctx.Items.Add("LastError", errorInfo);
ctx.Server.ClearError();
}
try
{
ctx.Response.Redirect(directUrl);
}
catch
{ }
//ctx.Server.Transfer(directUrl);
}
2.在错误页中获取错误信息并显示出来
- .net跳到指定错误页面兵显示详细的错误信息
- asp.net 获取错误信息并到指定页面
- asp.net中当服务器出错时显示指定的错误页面,同时把错误信息写入系统日志文件的探讨
- 在moss页面出错时,显示详细的错误信息. (zt)
- IIS7显示ASP的详细错误信息到浏览器
- 获取错误信息并到指定页面
- 获取错误信息并到指定页面
- asp.net中当服务器出错时显示指定的错误页面
- 分享 ASP.Net 网站设置 404错误跳转到指定页面的三种方法
- Tip - SharePoint - 显示详细的Debug错误信息
- 让SharePoint直接显示详细的错误信息
- 让IIS 7显示ASP的详细错误信息-无论什么样的代码错误,只显示“500 - 内部服务器错误解决
- IIS7.5显示ASP的详细错误信息”500 – 内部服务器错误解决”
- jsp中给出404/500错误,跳到指定的错误页面
- 页面错误信息显示的小案例
- 显示服务器端详细错误信息
- sharepoint显示详细错误信息
- ASP显示页面错误信息
- 程序异常指向 错误页 方法
- this 指针
- 为神马每次我下载后评论,积分都没返还?!
- sql存储过程
- preLoader
- .net跳到指定错误页面兵显示详细的错误信息
- ecos 自带的Microwindows中加入mwin的支持
- ubuntu apache2配置
- 教室规划问题(top-down)动态规划
- 自动化测试脚本开发的几种策略
- MII、RMII、SMII、GMII接口简介
- 用脚本删除N天以前的文件详解
- json笔记
- jvm加载class类机制