We all know url in ASP.NET MVC always like example.com/controller/action?param1=value1¶m2=value2
I'd like to know is there a way to put action name in query string just like example.com/controller?aciton=index¶m1=value1¶m2=value2
(notice action=index in query string), and make ASP.NET MVC route the url to the corresponding controller and action. The name of the query name can be action
or something else.
--- update 28th Sep ---
The actual situation is I have a form, inside the form is a table with radio button each column and some button (create, edit, delete etc.) above the table. These buttons go to different action in same controller.
As a result of search, I've got some solutions:
- handle onsubmit via JavaScript and change the action property of form. Answer link
- write a "route" method in controller to re-route the request. Answer link ( I think this is not a graceful solution )
- write a custom attribute let ASP.NET MVC route to corresponding action base on query. This anwser and this answer ( Very close to my original idea, I am currently using this solution )