1

我正在尝试将~/的默认路由设置为Area 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 }
        );
    }

但是,它错误表明转到站点的根“/”是一个例外,因为找不到控制器/操作。

我设置的区域错误吗?

我在该地区有一个主页和索引,可以通过它的路线很好地到达该地区:

        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
4

0 回答 0