I have the new .NET WebAPI up and running and I am trying to add a new route to my project so that I can see the SettingsController in action. I have added my route to the Global.asax file within the RegisterRoutes method but I receive a 404 error when I try and browse to: sampleUrl:12345/settings/index. I am able to see: sampleUrl:12345/home/index without issue.
Global.asax
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Settings",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Settings", action = "Index", id = UrlParameter.Optional }
);
}
Do I need to have an ActionResult Index() in my SettingsController?