I need help crating a permalink like URL routing in a MVC website.
The Slugs are already set up as www.xyz.com/profile/{slug}: the code is:
routes.MapRoute(
name: "Profile",
url: "profile/{slug}",
defaults: new { controller = "ctrlName", action = "actionName" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
What i need to achieve is a URL that you see on Wordpress permalinks or Umbraco permalinks. I need to have www.xyz.com/{Slug}.
I have tried to use:
routes.MapRoute(
name: "Profile",
url: "{slug}",
defaults: new { controller = "ctrlName", action = "actionName" }
);
But that did not work for me.
EDIT:
If I switch the route configs above, the slug functionality works but the regular routing no longer does.
Does that mean that I am forced to implement permalink functionality on all pages?