vu nguyen tien
vu nguyen tien

Reputation: 11

Error URL in mvc 4

Need help. This is Routeconfig:

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

This is my menu:

<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>

When i clicked into link example <b href="danh-muc/hd-tv">HD-TV</b> it'll call url http://localhost:50177/danh-muc/danh-muc/hd-tv

Upvotes: 1

Views: 108

Answers (1)

TechnicalTophat
TechnicalTophat

Reputation: 1725

You need a leading slash to show that it's a root directory. However, a much better idea would be to use @Html.ActionLink. It's a cleaner and easier way to link :-)

Upvotes: 1

Related Questions