0

我正在使用动态路由配置:

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 }
    );
}

但是这些网址长期无效。(例如:localhost/123/Product_Name几小时后激活)

预先感谢您的帮助

4

1 回答 1

0

是的,你可以只有一个路由器

routes.MapRoute(
               name: "MyUrlRouter",
               url: "{id}/{url}",
               defaults: new { controller = "Urunler", action = "Detay", id = UrlParameter.Optional }
           );

应该做。

于 2020-03-31T13:06:32.243 回答