asp.net mvc 3 - override OnActionExecuting for testing request does user authorised for call action or not? -
i override controller onactionexecuting method, , check action , controller user has right or not.
public class browsecontroller : controller { protected override void onactionexecuting(actionexecutingcontext filtercontext) { //todo: ask service user has right action. //string actname = filtercontext.actiondescriptor.actionname; //string cntname = filtercontext.actiondescriptor.controllerdescriptor.controllername //foo(actname, cntname, userinfo) if return false go noaccess page! //filtercontext.result = new redirectresult("_noaccessright"); base.onactionexecuting(filtercontext); } } i suppose after user right validation
filtercontext.result = new redirectresult("_noaccessright"); but not page "_noaccessright" , ~/shared/_noaccessright"
could please give idea? thanks.
to later
public class browsecontroller : controller { protected override void onactionexecuting(actionexecutingcontext filtercontext) { filtercontext.result = new redirecttoaction("noaccessright"); } public actionresult noaccessright() { return view("_noaccessright"); } }
Comments
Post a Comment