I have a controller called HomeController with the actions Index(), MethodOne() and MethodTwo(). Each of these just return View() for now.
When I create an action link with the code:
@Html.ActionLink("Home", "Index", "Home")
I get the hyperlink:
<a href="/">Home</a>
This is good however using the same ActionLink extention method to route too MethodOne I get the hyperlink:
<a href="/Home/MethodOne">MethodOne</a></li>
What do I need to configure so my site will accept the hyperlink “/MethodOne”, this currently returns a 404.
I have a suspicion this may be related to routing. My routing table is currently the default:
routes.MapRoute("Default", "{controller}/{action}/{id}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
});
You need a route like:
That will map and catch the request to the
Home/MethodOneaction method.