I am required to implement a simple webapp for a online competition for a simple game.
I need to handle a Get request and respond to that.
I thought, let's just use a bare ASP.Net MVC app, and let it handle the URL.
Problem is, the URL I need to handle is :
http://myDomain.com/bot/?Action=DoThis&Foo=Bar
I tried:
public ActionResult Index(string Action, string Foo)
{
if (Action == "DoThis")
{
return Content("Done");
}
else
{
return Content(Action);
}
}
Problem is, the string Action always gets set as the action name of the route.
I always get:
Action == "Index"
It looks like ASP.Net MVC overrides the Action parameter input, and uses the actual ASP.Net MVC Action.
Since I cannot change the format of the URL that I need to handle: is there a way to retrieve the parameter correctly?
Copyright Notice:Content Author:「Peterdk」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/2123951/asp-net-mvc-url-routing-how-to-deal-with-action-test-parameter