asp.net - Creating an action filter attribute that bypasses the actual execution of the action and returns a value for it -


can create actionfilterattribute bypasses actual execution of action , returns value it?

you can, this:

1) redirects action , return value:

public class myfilterattribute : actionfilterattribute {     public override void onactionexecuting(actionexecutingcontext filtercontext)     {         /*if happens*/         if (/*condition*/)         {             /*you can use redirect or redirecttoroute*/             filtercontext.httpcontext.response.redirect("redirecto somewhere");         }          base.onactionexecuting(filtercontext);     }  } 

2) write value direcly request , ends sending client:

public class myfilterattribute : actionfilterattribute {     public override void onactionexecuting(actionexecutingcontext filtercontext)     {         /*if happens*/         if (/*condition*/)         {             filtercontext.httpcontext.response.write("some value here");             filtercontext.httpcontext.response.end();         }          base.onactionexecuting(filtercontext);     }  } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -