I have an ASP.NET MVC website. The issue I am having is if I add a querystring, it can't render the view
My controller is
public class UpgradeController : Controller
{
public ActionResult Index(string id)
{
return View(id);
}
}
Simple as that
If I navigate to
localhost:123456/upgrade/index
Then the view is rendered in the browser as expected.
As you can see in the controller, the view Index takes a string parameter called id.
This should mean the following URL will return the same view
localhost:123456/upgrade/index/abc
Sadly, it does not render the expected view. Instead I see
The view 'abc' or its master was not found or no view engine supports the searched locations. The following locations were searched:
The same is true with the following URL
http://localhost:53081/upgrade/index?id=abc
I have only 1 route
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
I am totally baffled as to why it's trying to render a view and treating it like a parameter