【发布时间】:2016-12-28 08:44:35
【问题描述】:
我有一个这样的网址:
http://localhost:17594/Contact/Contact
现在我想这样显示:
http://localhost:17594/Contact/Contact-us
路由配置:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Categories",
url: "Categories/{id}",
defaults: new { controller = "Categories", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "FinalKaminet.Controllers" }
);
routes.MapRoute(
name: "Contacts",
url: "{controller}/{title}",
defaults: new { controller = "Contact", action = "Contact", title = UrlParameter.Optional },
namespaces: new[] { "FinalKaminet.Controllers" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}/{title}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional , title = UrlParameter.Optional },
namespaces: new[] { "FinalKaminet.Controllers" }
);
}
查看
@Html.ActionLink("Contact Us", "Contact" , "Contact" , new { title = "contact-us" } , null)
但我在使用Categories 地图路线的第 63 行遇到错误。
异常详情:System.InvalidOperationException: No route in the 路由表与提供的值匹配。
来源错误:
第 62 行:@Html.ActionLink("وبلاگ", "")
第 63 行:@Html.Action("MenuCat" , "Home")
怎么了?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-routing url-routing