c# - Use RedirectToRouteResult with Area failed -


i'm using custom filter check user access permission specific action , have area called admin. when filter redirect unauthorized user, redirected inside area not view in route directory.
example, when access http://localhost/admin/roles expect unauthorized user redicreted http://localhost/authorized not http://localhost/admin/authorized it's now.
here how 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 specify area en empty string:

filtercontext.result = new redirecttorouteresult(new routevaluedictionary                        {                            { "action", "index" },                            { "controller", "unauthorized" },                            { "area", string.empty }                        }); 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -