当我 运行 它打开的解决方案不是 mvc 中的默认页面

When I run the solution it opens not the default page in mvc

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

    }

}

我不知道为什么它在这个位置打开了http://localhost:00000/Views/Dashboard/Index.cshtml

能做什么?

试试这个

1) 右键单击​​您的项目解决方案

2) Select 属性

3) Select Web 选项然后 Select 当前页面

您好,请使用此代码。

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "YourProjectDLLName.Controllers" }
            );
        }

确保不要忘记添加项目 DLL 的命名空间。 执行此操作后构建您的项目并调试。