asp.net 4.0自定义401.2未经授权自定义页面 [英] asp.net 4.0 Custom 401.2 not Authorized custom page

查看:152
本文介绍了asp.net 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未经授权自定义页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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