我正在尝试将〜/ 的默认路由设置为区域 OnlineUser :
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index",
area="OnlineUser", id = UrlParameter.Optional }
);
}
但是它出错了,表明转到站点的根“/”是一个例外,因为ti找不到控制器/动作。
我设置区域错了吗?
我在区域内有一个住宅和索引,可以通过其路线很好地到达该区域:
context.MapRoute(
"OnlineUser_default",
"OnlineUser/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
确切错误是:
The view 'Index' or its master was not found or no view engine supports the
searched locations. The following locations were searched:
~/Views/Home/Index.aspx ~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml ~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml