配置 RouteConfig.cs

在 App_start 資料夾中開啟 routeconfig.cs 並執行此操作

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