Hi,
I'm currently using RedirectToRouteResult as follow:
public void OnAuthorization(AuthorizationContext filterContext)
{
User user = filterContext.HttpContext.Session["user"] as User;
if (user == null || user.Role != expectedRole)
{
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary{ {"controller", _controller}, {"action", _action} });
}
}
This code is in my CheckLoginAttribute class.
I intend to use it as decorator on specific controller actions for example:
[CheckLogin(RolesEnum.Member, "MyController", "MyAction")]
public JsonResult GetNews()
So basically, I'm trying to short circuit a call to GetNews() and skip the execution of the action if the user is not logged on. If the user is not logged on then I want it to redirect to another action.
Will "RedirectToRouteResult" redirect to the appropriate action server side without having to do a big loop through the client side (like rewritting window url location or something like that) ? Is that how it works ?
Thanks for the help Appreciated