asp.net 4.0自定义401.2未经授权自定义页面

编程入门 行业动态 更新时间:2024-10-26 03:23:02
本文介绍了asp 4.0自定义401.2未经授权自定义页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我成功地实施了基于角色的授权在ASP.NET中。当一个人不具备必要的角色,他得到来查看401.2未经授权错误页面。我现在想做到的是让我的应用程序自定义381页,并将它通过在web.config中设置重定向那里。我想这样的:

I successfully implemented role based authorization in ASP.NET. When a person does not have the needed role he gets to see an error page for 401.2 not authorized. What I would like to accomplish now is to have a custom 401 page in my application and have it redirected there via settings in the web.config. I tried this:

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"><error statusCode="401" redirect="NoAccess.htm" /></customErrors>

但是,这并不被逮住。我一定要覆盖它在IIS中呢?我希望不是因为这样做把事情更难部署

But this does not get caught. Do I have to override it in IIS instead? I hope not as that would make getting things deployed harder

推荐答案

我想你可能会运行到是你的安全设置整个应用程序。即当发生401,因为用户不具有访问该文件或者重定向到NoAccess.htm失败。既然你没有张贴整个文件我不能肯定,但是这是我最好的猜测。

I think what you might be running into is that you have security set for the entire application. That is when a 401 occurs the redirect to NoAccess.htm fails because the user does not have access to that file either. Since you didn't post the whole file I cannot be sure, but that is my best guess.

请确保您有一个&LT;位置路径=/ NoAccess.htm&GT;&LT;&的System.Web GT;&LT;授权&GT;&LT;让用户=? /></authorization<</system.web>在你的web.config文件。

Make sure that you have a <location path="/NoAccess.htm"><system.web><authorization><allow users="?" /></authorization<</system.web> in your web.config file.

更多推荐

asp.net 4.0自定义401.2未经授权自定义页面

本文发布于:2023-11-14 10:34:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586979.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   未经授权   页面   net   asp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!