User1091869387 posted
Tied to make seo friendly routing for mvc project to add title of product in the url, along with an id of the product.
RouteCondig generates the url that I want but I can't create the link to the Url in Razor View.
// Controller Action
public ActionResult DetailProperty(long propertyid, string titel)
{
...
// URL SEO
titel = house.title.Replace(" ", "-");
}
// Razor View
<a href="@Url.Action("DetailProperty", "tblProperty_Management", new { propertyid = item.tblProperty_Management.propertyid})"><img src="http://.../images/@item.picture_file" /></a>
// RouteConfig
routes.MapRoute(
name: "Detail pand",
url: "tekoop/{titel}-{propertyid}",
defaults: new
{
controller = "tblProperty_Management",
action = "DetailProperty",
titel = UrlParameter.Optional,
propertyid = UrlParameter.Optional
}
);
> Result
Generated URL with routing: https://localhost:44379/tekoop/Interessante-gezinswoning-op-200m-van-centrum-2069738
Url when hovering the link/image: https://localhost:44379/tekoop/-2069738
--> So I' missing the title in the Url of RazorView to reach my page.
I must be missing something here..