c# - How to use public property in actioninvoke in asp.net mvc? -
i have code
public actionresult index() { if (currentuser != null) { usermanager.user usr = (user.user)currentuser; } }
i have done admincontroller : testcontroller
now way access currentuser in actioninvoke use check user admin or not
public class adminauthorize : actionfilterattribute { public override void onresultexecuting(resultexecutingcontext filtercontext) { base.onresultexecuting(filtercontext); } }
is anyway use currentuser variable in invoker.
you should able access current controller instance controller property of filtercontext.
public class adminauthorize : actionfilterattribute { public override void onresultexecuting(resultexecutingcontext filtercontext) { base.onresultexecuting(filtercontext); var currentuser = ((admincontroller)filtercontext.controller).currentuser; // need currentuser } }
Comments
Post a Comment