I'm using custom filter that check user access permission to specific Action and I have area called Admin. When filter redirect unauthorized user, its redirected inside area but not to the view in route directory.
For example, when I access http://localhost/admin/roles I expect that unauthorized user will be redicreted to http://localhost/authorized but not to http://localhost/admin/authorized as it's now.
Here is how I use filter:
public override void OnAuthorization(AuthorizationContext filterContext)
{
DigitalHubOnlineStoreEntities db = new DigitalHubOnlineStoreEntities();
RbacUser requestingUser = new RbacUser();
var controllerid = RbacUser.GetControllerId(filterContext.ActionDescriptor.ControllerDescriptor.ControllerName);
var actionid = RbacUser.GetActionId(filterContext.ActionDescriptor.ActionName, controllerid);
if (!requestingUser.GetUserPermission(HttpContext.Current.User.Identity.Name, actionid, controllerid))
{
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "Unauthorized" } });
}
}
You need to specify
Area
with en empty string: