I have the following map route in my route config. This is the first route before anything else.
routes.MapRoute(
"HomePage",
"",
new { area = "Accessibility", controller = "Cardholders", action = "Index" }
);
However, when I view my website in browser, I get
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Cardholders/Index.aspx
~/Views/Cardholders/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Cardholders/Index.cshtml
~/Views/Cardholders/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
I have no issues when I browse my action directly http://localhost:54358/accessibility/cardholders/index
What I want to achieve, is to type http://localhost:54358
and it redirects to http://localhost:54358/accessibility/cardholders/index
Based on the answers below, I have tried
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Cardholders", action = "Index", id = UrlParameter.Optional},
// Parameter defaults
new[] { "Plan.Web.Mvc.Areas.Accessibility.Controllers" }
);
and
routes.MapRoute(
"HomePage",
"Accessibility_Default",
"Accessibility/{controller}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
and
routes.MapRoute(
"HomePage",
"Accessibility_Default",
"Accessibility/{controller}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
All don't seem to work.