asp.net mvc - custom filter attribute and custom authorize attribute execution -
asp.net mvc - custom filter attribute and custom authorize attribute execution -
i have controller wide filter attribute below :
public class loggingnhibernatesessionattribute : actionfilterattribute { private readonly iactionexceptionhandler _actionexceptionhandler; private readonly iactiontransactionhelper _actiontransactionhelper; public loggingnhibernatesessionattribute() : this( webcontainermanager.get<iactionexceptionhandler>(), webcontainermanager.get<iactiontransactionhelper>()) { } public loggingnhibernatesessionattribute( iactionexceptionhandler actionexceptionhandler, iactiontransactionhelper actiontransactionhelper) { // _actionloghelper = actionloghelper; _actionexceptionhandler = actionexceptionhandler; _actiontransactionhelper = actiontransactionhelper; } public override void onactionexecuting(actionexecutingcontext actioncontext) { // _actionloghelper.logentry(actioncontext.actiondescriptor); _actiontransactionhelper.begintransaction(); } public override void onactionexecuted(actionexecutedcontext actionexecutedcontext) { _actiontransactionhelper.endtransaction(actionexecutedcontext); _actiontransactionhelper.closesession(); //_actionexceptionhandler.handleexception(actionexecutedcontext); //_actionloghelper.logexit(actionexecutedcontext.actioncontext.actiondescriptor); } }
here usage :
[loggingnhibernatesession] public class basecontroller : controller { }
i have custom authorize attribute:
public class customauthorizeattribute : authorizeattribute { }
and usage :
[customauthorize()] public actionresult index( int page = 1, int rows = 10) { }
for first time action executes, methods in loggingnhibernatesessionattribute
run, when refresh page (still on action) time methods in customauthorize
execute , methods in loggingnhibernatesessionattribute
not execute.
would help me please ?
i did't exactly, can that, can override mvc method
public interface iauthenticationfilter { void onauthentication(authenticationcontext filtercontext); void onauthenticationchallenge(authenticationchallengecontext filtercontext); }
here link creating custom authentication in mvc. must help you...!
asp.net-mvc fluent-nhibernate ninject
Comments
Post a Comment