基于子状态的自定义错误页面? [英] Custom error page based on sub-status?

查看:68
本文介绍了基于子状态的自定义错误页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前有一个学术问题,但引起了我的好奇.

编写自定义错误页面时,有什么方法可以捕获HTTP子代码(如果有)? web.config中的customErrors块仅允许整数状态,因此我无法区分403.4和403.14.而且我无法找到可以在Application_Error中拦截的此信息的异常.具体来说,我想将所有403错误重定向到单个页面,并让该页面描述特定的访问被拒绝"错误.

An academic question right now, but my curiosity has been piqued.

Is there any way to capture the HTTP sub-code, if any, when writing a custom error page? The customErrors block in web.config allows only for integer status, so I cannot distinguish between, say, 403.4 and 403.14. And I haven''t been able to find an exception with this information that I could intercept in Application_Error. Specifically, I would like to redirect all 403 errors to a single page and have that one page describe the specific "Access Denied" error.

Is this possible?

推荐答案

应该这样做:

This should do it:

HttpContext.Current.Response.SubStatusCode;


这篇关于基于子状态的自定义错误页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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