I have route in RouteConfig:
routes.MapRoute(
name: "AdsCategories",
url: "Ads/{key}",
defaults: new
{
controller = "Ads",
action = "Index",
key = UrlParameter.Optional
},
constraints: new
{
key = new ExcludingValuesConstraint(
"edit", "create", "details",
"delete", "AdsSlider", "UserAds",
"GetCitiesByRegion", "Index", "AddComent",
"search", "SetFilter")
},
namespaces: new string[] { "Vprok.Controllers" }
);
And the code that forms a link in htmlhelper:Link.MergeAttribute("href", urlHelper.Action(action, controller));
And if i go to page Ads/somekey. And use on this page helper: @Html.ActiveLi("Объявления", "Index", "Ads")
. That return "Ads/somekey" instead "Ads/".
Why UrlHelper.Action merged {key} parametr whith URL ?
Problem Solved. Tthis code return "Ads/": Link.MergeAttribute("href",urlHelper.RouteUrl("Default", new{ action, controller}));