【发布时间】:2017-01-04 20:18:00
【问题描述】:
我在使用 ASP 路由引擎时遇到了一些问题,这些问题不言自明。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "GameGold",
url: "Products/GameGold/{controller}/{action}/{id}",
defaults: new { controller = "Coins", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
当我转到 URL localhost/Products/GameGold/Coins/ 时,就会出现这个。
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Coins/Index.aspx
~/Views/Coins/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Coins/Index.cshtml
~/Views/Coins/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
我的文件夹是这样布置的
/Views/Products/GameGold/Coins/Index.cshtml
【问题讨论】:
-
请注意,model-view-controller 标签是针对有关模式的问题。 ASP.NET-MVC 实现有一个特定的标记。
标签: c# asp.net-mvc asp.net-mvc-5 routing