Asp.net mvc Html.RouteLink即使使用正确的路由名称也无法生成正确的链接
我在_Layout.html中有以下内容Asp.net mvc Html.RouteLink即使使用正确的路由名称也无法生成正确的链接,asp.net-mvc,Asp.net Mvc,我在_Layout.html中有以下内容 @Html.RouteLink("test", "CityWithTypeSpecified", new { country = Model.CountryCode, state = Model.State, city = Model.CurrentCity.SubDomainName, description = type.Description, id = type.TypeID }) 当继承页由城市控制器提供服务时,链接生成良好,当继承页由另
@Html.RouteLink("test", "CityWithTypeSpecified", new { country = Model.CountryCode, state = Model.State, city = Model.CurrentCity.SubDomainName, description = type.Description, id = type.TypeID })
当继承页由城市控制器提供服务时,链接生成良好,当继承页由另一个控制器提供服务时,链接url为空
这是我的路线
routes.MapRoute(
name: "CityWithTypeSpecified",
url: "{country}/{state}/{city}/{description}/{id}",
defaults: new { controller = "City", action = "LoadByType" }
);
我做错了什么?解决了这个问题。。我的某些项目为空。。如果您遇到相同的问题,请确保任何给定字段的数据都不为空。对于routes.MapRoute,请尝试将url参数更改为:url:{controller}/{action}/{country}/{state}/{city}/{description}/{id}我有这样的url,它不再工作,因为路由已更改为包含controller