这个问题已经讨论过很多次了,但我还没有找到适合我的特殊情况的解决方案。
在我的 Umbraco (6) 视图之一中,我通过使用调用控制器方法
@Html.Action("Index", "CountryListing");
这会导致“路由表中没有路由”异常。
我一直在摆弄 RegisterRoutes 方法无济于事。我想知道当我清空 RegisterRoutes 方法时,它是否甚至被用作站点仍然可以运行。这就是它现在的样子:
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 }
);
}
我也试过像这样在通话中添加一个空的“区域”
@Html.Action("Index", "CountryListing", new {area: String.Empty});
我在其他地方使用@Html.Action 语句并且它们确实有效,所以我确实理解为什么其中一些有效而另一些无效,但现在的主要问题是让我的国家/地区列表行动起作用。