Friday 15 July 2011

c# - Is it possible to have a parameter named action in MVC4? -



c# - Is it possible to have a parameter named action in MVC4? -

please mark duplicate - its answered here

is possible have parameter named action in mvc4?

trying results in parameter returning me name of controller action rather parameter value.

/somecontroller/someaction?action=value

when seek access parameter action, "someaction" result rather "value".

trying bind parameter different name doesn't help either.

public actionresult someaction([bind(prefix = "action")] string id)

edit: have not found 'action'/'action' in reserved mvc keywords either.

i haven't tested this, assume seek changing url of default route other action

routes.maproute("default", "{controller}/{action}/{id}", new { controller = "home", action = "index", id = urlparameter.optional });

to

routes.maproute("default", "{controller}/{caction}/{id}", new { controller = "home", caction = "index", id = urlparameter.optional });

this should allow utilize action parameter in action. i'm not why you'd want this, build route url accepted action , built part of url similar this:

/somecontroller/someaction/value value "action" parameter.

edit based on comments:

i created route goes aspx url'd route

routes.maproute(null, "third-party.aspx", new { controller = "home", action = "index" });

obviously can add together whatever controller/action want here , want handle it, access route via /third-party.aspx?action=value , seemed work me

c# asp.net-mvc asp.net-mvc-4

No comments:

Post a Comment