Answer the question
In order to leave comments, you need to log in
How to set up a route without an ID?
Hello!
I want this route to be beautiful: mysite/blog/statia-odin
but it only comes out like this: mysite/blog/statia-odin/1
code:
//маршрут
routes.MapRoute(
"BlogDetailed",
"Blog/{SeoUrl}/{id}",
new { controller = "Blog", action = "BlogDetailed", SeoUrl = UrlParameter.Optional },
new { id = @"^\d+$" }
);
//контроллер
public ActionResult BlogDetailed(int id, string SeoUrl)
{
return View(BM.BlogDetailed(id));
}
Answer the question
In order to leave comments, you need to log in
If the id is not passed, then
Blog/{SeoUrl}
and the search by the name of the article itself are not passed.
What is so unsatisfactory?
Blog/{SeoUrl}-{id}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question