Routing mvc5动态路由和指向它的Html.ActionLink

Routing mvc5动态路由和指向它的Html.ActionLink,routing,asp.net-mvc-5,html.actionlink,Routing,Asp.net Mvc 5,Html.actionlink,这个动态路由功能运行良好 public class CategoryRouteConstraint : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { //these would usual

这个动态路由功能运行良好

public class CategoryRouteConstraint : IRouteConstraint
{
    public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
    {
        //these would usually come from a database, or cache.
        FlyingCarpetMVC.Models.MyDbContext db = new FlyingCarpetMVC.Models.MyDbContext();
        var categories = db.Country_name.Select(x => new {x.English_name,x.Spanish_name}).ToList();

        if (values[parameterName] == null)
            return false;

        //get the category passed in to the route
        var category = values[parameterName].ToString();
        category = category.Replace("-", " ");
        category = category.Replace("_", " ");
        //now we check our categories, and see if it exists
        bool Exist = categories.Any(x => x.English_name.Contains(category) || x.Spanish_name.Contains(category));
        return Exist;
        // url such as /restaurants/Camberley--Surrey will match
        // url such as /pubs/Camberley--Surrey will not
    }
}

 routes.MapRoute(
            name: "CategoryRoute",
            url: "{category}/{location}",
            defaults: new { controller = "Home", action = "kind", Country = UrlParameter.Optional,trip=UrlParameter.Optional },
            constraints: new { category = new CategoryRouteConstraint() }
            );
我希望超链接像“/kind/Trip”

当我让它像

 @Html.ActionLink(MyThisTripName,"kind", new {Kind=CountryNam,Trip= MyThisTripName },null)
它给我的url像

href=“/Home/kind?Country=埃及度假旅行=古典之旅”

我想要

href=“埃及之旅/古典之旅”


请帮助

尝试在URL路线配置中添加国家/地区和行程参数

routes.MapRoute(
            name: "CategoryRoute",
            url: "{category}/{location}/{Country}/{Url}",
            defaults: new { controller = "Home", action = "kind", Country = UrlParameter.Optional,trip=UrlParameter.Optional },
            constraints: new { category = new CategoryRouteConstraint() }
            );

我把[Route(“{Country}/{trip}/”)放在我的控制器类上,直接按我的意愿路由到它,但它路由到每个java脚本和css文件。我需要立即帮助。如果你知道任何人如何在facebook或其他地方提供帮助,或者标记他