开发者

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(); }

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜