我希望我的 ASP.NET MVC 应用程序默认重定向到产品控制器索引操作。所以我将 RouteConfig 更改为
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Product", 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
我调试了应用程序并检查了第三条路线的默认部分。但它仍然说
{[controller, Home]}
谁能告诉我为什么?