开发者

Hide/Show content using ActionFilterAttribute/AuthorizeAttribute

开发者 https://www.devze.com 2023-01-12 10:58 出处:网络
I\'m using MVC 2 with futures, and I\'m trying to hide/show content based on role.Is there a way with ActionFilterAttribute or AuthorizeAttribute if the authentication fails to not show the controller

I'm using MVC 2 with futures, and I'm trying to hide/show content based on role. Is there a way with ActionFilterAttribute or AuthorizeAttribute if the authentication fails to not show the controller child action开发者_如何学Python all through attributes? Or is all I can do with those attributes is redirect or throw up an error message? I just need the child action to return nothing basically if it fails the authentication.


Looks like you can just assign the result to a blank ActionResult.

protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { filterContext.Result = new System.Web.Mvc.EmptyResult(); }

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号