Bas*_*sic 4 vb.net asp.net-mvc authorization
我正在使用该Authorize()属性来保护我的控制器/操作,并且只希望向未经身份验证的用户显示"登录"操作 - 或者以另一种方式显示,拒绝访问经过身份验证的用户.
我无法在网上找到任何拒绝权限或允许否定权限的内容(即!LoggedIn)
有人可以指点我正确的方向吗?
MVC2,.Net 4
编辑:为了clairfy,我想要这样的事情:
Public Class PublicController
Inherits ControllerBase
<Authorize()> 'Only logged-in users can logout
Public Function Logout() as ActionResult
Return View()
End Function
'Something here to indicate that only NON-authorized users should see this action
Public Function Login() as ActionResult
Return View()
End Function
End Class
Run Code Online (Sandbox Code Playgroud)
Joh*_*ell 13
它可以像这样简单:
public class DenyAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return !base.AuthorizeCore(httpContext);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4330 次 |
| 最近记录: |