I'm just learning MVC and am trying to create a SEO page title, therefore I'm sending an ID for the controller but also the page slug for the SEO.
I want to see Recipe/Details/18/foobar
but the below code returns
Results/Name/18?name=foobar
I presume its an issue with my custom Route but from all mt Research I think I'm doing it correctly. Any assistance is appreciated.
_PartialView
<a href="@Url.Action("Details", "Recipe", new {id = Recipe.ID, name = Recipe.Slug}, null)">
RouteConfig
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Recipe",
url: "{controller}/{action}/{id}/{name}",
defaults: new {
controller = "Recipe",
action = "Details",
id = UrlParameter.Optional,
name = UrlParameter.Optional
}
);
Controller
public ActionResult Details(int id)