在全局globa中的application error中处理的//页面不存在的错误
//Context.Response.Clear();
Response.Status = "404 Not Found";
//Context.Response.StatusCode = Convert.ToInt32(HttpStatusCode.NotFound);
Response.AddHeader("Location", "http://localhost:24531/web/serverErr.html");问题是
我在另一个分支数据库错误505时,跳转到一个html页面,请问如何保证505状态
使用redirect返回了200正确值。
使用Response.AddHeader也并没有跳转到servererr.html页面中。
//Context.Response.Clear();
Response.Status = "404 Not Found";
//Context.Response.StatusCode = Convert.ToInt32(HttpStatusCode.NotFound);
Response.AddHeader("Location", "http://localhost:24531/web/serverErr.html");问题是
我在另一个分支数据库错误505时,跳转到一个html页面,请问如何保证505状态
使用redirect返回了200正确值。
使用Response.AddHeader也并没有跳转到servererr.html页面中。
解决方案 »
- gridview导出excel的问题请教!
- 怎样显示/隐藏htmltable中的列!
- 急,急,急啊 驗証時間
- 怎样取得datagrid模版列中一个隐藏控件的值?aspx和cs怎么写?
- 注册时邮箱验证的原理是什么?(50分)
- 也许,可是DropDownList
- *************求书深入剖析ASP.NET组件设计(作者:黄忠诚)******
- 请教问题:在线等!
- 有那位有在WEB上实现打印的控件,或利用IE打印功能但不用菜单或工具拦内的打印,自己作的IE打印事件,具有打印,御览,页面调整等功能?
- ListBox控件在ASP怎样实现水平滚动条。
- 客户端已安装powerpoint,怎么直接在页面显示ppt,而不是弹出下载提示框图
- 查询分析器中查出的和直接在SQl表中查出来的不一样。
context.Response.Status = "404 Not Found";
//Context.Response.StatusCode = Convert.ToInt32(HttpStatusCode.NotFound);
context.Response.AddHeader("Location", "http://localhost:24531/web/serverErr.html");
并没有跳转到目标页面,所以就redirect得
// 在出现未处理的错误时运行的代码 Exception ex = Server.GetLastError().GetBaseException();
if (ex.GetType() == typeof(HttpException))
{
if (((HttpException)ex).GetHttpCode() == 404)
{
//页面不存在的错误
//Context.Response.Clear();
Response.Status = "404 Not Found";
Response.StatusCode = Convert.ToInt32(HttpStatusCode.NotFound);
Response.AppendHeader("Location", "http://localhost:24531/web/serverErr.html");
}
else
{
}
}
else if (ex.GetType() == typeof(System.Data.SqlClient.SqlException))
{
Context.Response.Redirect("serverErr.html");
}
else
{
}现在问题:
404错误,还是在黄色页面,并没有跳到servererr.html
500(数据库异常),跳转过去,但是状态这时由于是redirect,变成了200,监视程序捕捉的时非原页面的状态。
我想:404可以跳到html页面,500最好也使用404的代码,并且保持住500的状态。
记得在301跳转在aspx后台写实可以的,不知道在global中写是不是有些什么不同了。
不愿意使用web.config配置和iis配置来实现这个问题
直接跳不就行了
Respone.Redirect("http://localhost:24531/web/serverErr.html");