C# MVC4中的错误URL

C# MVC4中的错误URL,c#,asp.net-mvc-4,C#,Asp.net Mvc 4,我需要帮助。这是Routeconfig: routes.MapRoute( name: "camera", url: "danh-muc/{CategoryName}", defaults: new { controller = "Product", action = "CategoryPro", id = UrlParameter.Optional }, namespaces: new[] { "ThietBiAnNinh.Controllers" } ); 这是我的

我需要帮助。这是Routeconfig:

routes.MapRoute(
    name: "camera",
    url: "danh-muc/{CategoryName}",
    defaults: new { controller = "Product", action = "CategoryPro", id = UrlParameter.Optional }, namespaces: new[] { "ThietBiAnNinh.Controllers" }
);
这是我的菜单:

<b href="danh-muc/hd-tv">HD-TV</b>
<b href="danh-muc/led-tv">HD-TV</b>
<b href="danh-muc/lgd-tv">HD-TV</b>
高清电视 高清电视 高清电视 当我点击链接示例
HD-TV

它将调用url
http://localhost:50177/danh-muc/danh muc/hd tv

您需要一个前导斜杠来显示它是根目录。然而,更好的办法是使用
@Html.ActionLink
。这是一种更简洁、更简单的链接方式:-)

,因为缺少了使路径绝对化的前导斜杠(
/danh muc/hd tv
)。但是,您确实应该为此使用
Url.Action()