我的路由配置中有以下映射路由。这是其他任何事情之前的第一条路线。将控制器和区域内的操作设置为默认页面
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 }
);
似乎都没有工作。
这不起作用 –