我正在使用动态路由配置:
foreach (var urn in db.Urunler.Where(x => x.UrunKategori.DilId == item.Id).ToList())
{
routes.MapRoute(
name: "Urun" + urn.Id,
url: @urn.Id + "/" + @urn.UrnUrl,
defaults: new { controller = "Urunler", action = "Detay", id = @urn.Id }
);
}
但是这些url在很长一段时间内都是无效的。(例如:localhost/123/Product_Name
在几个小时后激活(
提前感谢您对的帮助
是的,你可以只有一个路由器
routes.MapRoute(
name: "MyUrlRouter",
url: "{id}/{url}",
defaults: new { controller = "Urunler", action = "Detay", id = UrlParameter.Optional }
);
应该这样。