剔除授权在ASP.NET MVC 2的动作 [英] Excluding an action from authorization in ASP.NET MVC 2

查看:121
本文介绍了剔除授权在ASP.NET MVC 2的动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的ASP.NET MVC应用程序Forms身份验证。我想从授权过程的注册页面。我知道我可以在我的主web.config文件中添加位置标记或创建特定的文件夹内一个新的web.config文件。但我只是排除在用户控制器的一个具体行动。我该怎么做呢?

I am using forms authentication in my ASP.NET MVC application. I want to the signup page from the authorization process. I know I can add a location tag in my main web.config file or create a new web.config inside the specific folder. But I just to exclude one specific action in the User controller. How do I do it?

推荐答案

不要使用Web.config文件<地点>授权在MVC应用程序。这样做将导致安全漏洞在您的网站。

Do not use Web.config <location> authorization in an MVC application. Doing so will lead to security vulnerabilities in your web site.

相反,使用[授权]属性来控制谁可以访问特定的控制器或动作。 (如果你想让它适用于该控制器的所有操作,您可以使用一个控制器的类型[授权]属性)。

Instead, use the [Authorize] attribute to control who has access to certain controllers or actions. (You can use the [Authorize] attribute on a controller's type if you want it to apply to all actions in that controller.)

更多信息:

这篇关于剔除授权在ASP.NET MVC 2的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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