ASP.Net MVC Routing/Using Dynamic Actions -
ok trying build controller has following action methods
public actionresult executestep_1a public actionresult executestep_1b public actionresult executestep_2
etc...
is there way define route uses parameter concatenated action name? instance url /step/executestep_1a. tried defining route url equal to:
{controller}/{action}_{number}
with no success. tried few other permutations again no results. if point me in right direction i'd appreciate it. oh set action equal executeresult_ default if adds explanation any.
you can use root action , them use reflection that:
{controller}/{action}/{step} public actionresult executestep(string step){ try { type thistype = this.gettype(); methodinfo themethod = thistype.getmethod("executestep_" + step); return themethod.invoke(this, null); } catch {} }
but there speed limitation, if using reflection.
Comments
Post a Comment