动作过滤器属性的mvc securityexception

时间:2012-03-06 20:58:33

标签: model-view-controller asp.net-mvc-routing action-filter securityexception

因此,我使用ActionFilter属性的OnActionExecuting覆盖在我的Action上进行了此安全设置。

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
  RouteValueDictionary routeDeniedUsers = new RouteValueDictionary(new { controller = "Errorhandler", action = "NopeAintAllowed"});
 if(user.IsNotAllowed)
      throw new System.Security.SecurityException("You are not allowed to access page")
      return

 try{
///some process
}catch(SecurityException ex){
   if(ex != null)
        filterContext.Result = new RedirectToRouteResult(routeDeniedUsers);
}

}

所以我的问题是,一旦用户到达那里,如何向我的“routeDeniedusers”动作显示错误消息?我会使用TempData [“key”]但是visual studio只在工具提示上显示TempDataDictionary(或者你称之为显示语法的东西)。我想访问SecurityException实例,但我不知道如何。

我是否真的在传递中使用SecurityException对象,还是应该使用其他东西? 任何建议都表示赞赏。

谢谢, ģ

0 个答案:

没有答案
相关问题