MVC认证旁路一个控制器/动作 [英] MVC Authentication bypass for a single controller/action
问题描述
我使用MVC与窗体身份验证,我需要验证绕过我的控制器之一,是有可能的Cotroller(S)/动作(S)绕过验证。
我已经通过<一个href=\"http://stackoverflow.com/questions/1816625/asp-net-mvc-forms-authentication-and-unauthenticated-controller-actions\">http://stackoverflow.com/questions/1816625/asp-net-mvc-forms-authentication-and-unauthenticated-controller-actions ,但我不希望限制对用户/角色的任何行动,我要让它匿名。
I am using MVC with forms authentication and i need authentication bypass for one of my controllers, is it possible to bypass authentication for Cotroller(s)/Action(s). I have been through http://stackoverflow.com/questions/1816625/asp-net-mvc-forms-authentication-and-unauthenticated-controller-actions , but i dont want to restrict any action for a user/role , i want to allow it anonymously.
在这方面,任何人都可以提供帮助。
Can anyone help in this regard.
推荐答案
发布你的页面<一上的位置标签解决方案href=\"http://stackoverflow.com/questions/1816625/asp-net-mvc-forms-authentication-and-unauthenticated-controller-actions/1816726#1816726\">linked实际上了解MVC确实工作。周围的授权控制踢MVC框架有一个机会来处理请求之前:
The location tag solution posted on the page you linked to actually does work for MVC. The authorization controls around that kick in before the MVC framework has a chance to handle the request:
<configuration>
<location path="~/MyAnonymousController">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
另外请注意,你可以把子目录的Web.config文件在您的应用程序。因此,例如,你可以把你的匿名访问控制器在它自己的子目录,并与一个位置标记,目录添加一个web.config,允许在该目录中的一切匿名访问:<一个href=\"http://stackoverflow.com/questions/4375208/web-config-wildcards-in-location-and-authorization\">Web.config:在位置和授权通配符
这篇关于MVC认证旁路一个控制器/动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!