I'm making a small project that has a page that shows a list of applications available to download. My routing in RouteConfig.cs looks like this:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "ViewApplication",
url: "View/{applicationname}",
defaults: new { controller = "View", action = "ViewApplication"}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Where my controller looks like this:
public class ViewController : Controller
{
public ActionResult ViewApplication(string applicationname)
{
return View();
}
}
But whenever I try to navigate to localhost:50788/View/A610723 it fails, and the URL changes to localhost:50788/? and stays on the home page.
I've had a look at this question MVC 4: Custom Routes And its almost exactly the same as what I want to do, where they are using beername as a string, but mine isn't working.
Is there something I've missed?
Thanks