Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 5 not setting parameter named "action" to passed value

I have the following method:

public void Service(int id, string action)

When i hit this as a Url:

http://localhost/home/service?id=24&action=updated

MVC is setting my parameter "action" as "service" (the name of the method) regardless of what i pass in to the parameter.

Is there anyway to override this "action" parameter from MVC setting it (via routes or any attributes)?

like image 632
Gustavo Avatar asked Mar 19 '23 21:03

Gustavo


2 Answers

Request.QueryString["ACTION"]

if you are filling in an object with a member called action, it's possible that in the debugger it will appear this has not worked, but it has. check it with Console.WriteLine or another method.

like image 74
andypopa Avatar answered Apr 01 '23 10:04

andypopa


You'll need to rename the parameter to something else.

"action" is a special case in ASP.NET MVC, so you need to avoid using it for another purpose.

(Note: this does work correctly in WebAPI)

like image 42
demoncodemonkey Avatar answered Apr 01 '23 11:04

demoncodemonkey