自定义错误页面未显示在我的aspx页面上 [英] Custom error page not showing on my aspx page

查看:97
本文介绍了自定义错误页面未显示在我的aspx页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个代码:

Hi, I wrote a code:

protected void Application_Error(Object sender, EventArgs e)
{
  Response.Clear();
  Response.StatusCode = 200;
  Response.Redirect("~/abcd.aspx");
  Response.End;  
}   


我没有重定向到自定义错误页面.它显示服务器错误.
注意:我必须在web.config中将"customerror"模式设置为"Off",并且不能在代码中使用server.clearerror().

编辑============

仍未解决.


I am not redirecting to the custom error page. It shows the server error.
Note: I have to make customerror mode in web.config "Off" and I cannot use server.clearerror() in code.

EDIT ============

Still hasn''t been resolved.

推荐答案

也许您的路径无效.我使用这项技术来确保路径正确无误:

解析多文件夹网站中的路径 [ ^ ]



编辑==============

@zaidi-页面本身有问题.尝试使页面仅显示诸如我的错误页面"之类的简单内容,然后查看当您尝试重定向时是否显示了该页面.您也可以尝试注释掉此行:

Maybe your path is invalid. I use this technique to make sure the path is going to be correct:

Resolving Paths in a Multi-Folder WebSite[^]



EDIT ==============

@zaidi - Then there''s something wrong with the page itself. Try making the page just display something simple like "My Error Page", and see if it gets displayed when you to try to redirect. You might also try commenting out this line:

Response.End();






您可以尝试以下代码
You can try this code
protected void Application_Error(Object sender, EventArgs e)
{
  Response.Clear();
  Response.StatusCode = 200;
  Response.Redirect("~/error.aspx?Valid=ReqValidExp",false);
  
}   


这篇关于自定义错误页面未显示在我的aspx页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆