So I have this security setup on my Action using the OnActionExecuting override of the ActionFilter Attribute.
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);
}
}
so my question is, how do I display an error message to my "routeDeniedusers" Action once the users gets there? I would use TempData["key"] but visual studio only shows TempDataDictionary on the tool tip (or whatever you call that thing that shows the syntax). I would want to access the SecurityException instance but I odn't know how.
Should I really be using the SecurityException object in passing or should I use something else? Any advice is appreciated.
Thanks, G