Hide/Show content using ActionFilterAttribute/AuthorizeAttribute
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(); }
精彩评论