gen*_*eek 4 asp.net-mvc asp.net-membership asp.net-mvc-3
如何为控制器内的特定操作设置授权?
示例(授权登录的有效用户名):
[Authorize]
public ActionResult ChangePassword()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
所以,我希望根据用户角色验证访问权限......如下所示:
[Authorize]
[AuthorizeRole="Admin"] // This is psuedo but something like this
[AuthorizeRole="SuperUser"] // This is psuedo but something like this
public ActionResult ChangePassword()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
有可能像以上那样吗?如果不是基于特定控制器/操作安全性的角色来保护访问的最佳方法是什么?
谢谢!
Dan*_*ite 12
这就是你需要的.
[Authorize(Roles = "Admin, SuperUser")]
Run Code Online (Sandbox Code Playgroud)
请参阅:http://msdn.microsoft.com/en-us/library/dd460317.aspx
| 归档时间: |
|
| 查看次数: |
6535 次 |
| 最近记录: |