我的路线配置中有以下地图路线。这是第一条路线。
routes.MapRoute(
"HomePage",
"",
new { area = "Accessibility", controller = "Cardholders", action = "Index" }
);
但是,当我在浏览器中查看我的网站时,我得到
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
当我直接浏览我的操作时我没有问题http://localhost:54358/accessibility/cardholders/index
我想要实现的是输入http://localhost:54358
并重定向到http://localhost:54358/accessibility/cardholders/index
根据下面的答案,我已经尝试过
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" }
);
和
routes.MapRoute(
"HomePage",
"Accessibility_Default",
"Accessibility/{controller}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
和
routes.MapRoute(
"HomePage",
"Accessibility_Default",
"Accessibility/{controller}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
一切似乎都不起作用。