hello everyone good day I have a project with asp.net core I want to make a dynamic url structure in this project
route :
endpoints.MapControllerRoute(
name: "seourlparam",
pattern: "{culture}/{seourl}",
defaults: new { culture = "tr-TR", controller = "Home", action = "Index" }
);
basecontroller :
public override async Task OnActionExecutionAsync( ActionExecutingContext context, ActionExecutionDelegate next)
{
string seourl = context.RouteData.Values["seourl"] + "";
string controllername = context.RouteData.Values["controller"] + "";
string actionname = context.RouteData.Values["action"] + "";
if(!string.IsNullOrEmpty(seourl) && controllername == "Home" && actionname == "Index")
{
var Sayfa = dbContext.Sayfas.FirstOrDefault(x => x.URL == seourl);
if (Sayfa != null)
{
context.RouteData.Values["controller"] = Sayfa.ControllerName;
context.RouteData.Values["action"] = Sayfa.ActionName;
}
}
await base.OnActionExecutionAsync(context, next);
}
My problem is when I click on the link, for example, Controller: Page Action: Page Detail, but the view part is correct, but it sees the HomeController Index as the controller.
thank you if you help
What I have tried:
-My problem is when I click on the link, for example, Controller: Page Action: Page Detail, but the view part is correct, but it sees the HomeController Index as the controller.
thank you if you help