Im triying for a while build an action link with a desire route:
I have this action link:
@Html.ActionLink(" Continue Reading", // linkText"PostComplete", // actionName"Posts", // controllerName new { // routeValues id= Model.Id, title = Model.Title.Trim() } , new { @class = "readmore" } // htmlAttributes // htmlAttributes )
who call this controller:
[Route("posts/{title}")] public IActionResult PostComplete(long id) { var post = _dataContext.Posts.SingleOrDefault( x => x.Id == id); return View(post); }
the path when I click in the action link is:
http://localhost/posts/Learning%20it%20test?id=1 ,I have "trim()" in the link so I dont know why it still have the %20 whitespace (also tried with .Replace(" ","")) , I also dont want the
id there, I dont even understand why it is showing the id if I just have /posts/{title} in the route
I want something like:
http://localhost/posts/Learningittest