D
D
Dmitry Filandor2016-07-14 23:37:45
ASP.NET
Dmitry Filandor, 2016-07-14 23:37:45

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));
        }

how I didn’t try with the route so that the ID is not displayed - all the time the same error - the view was not found ....
Specialists, please tell me how to remove the ID from the view so that there is a clean, beautiful URL

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-07-14
@LifeAct

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 question

Ask a Question

731 491 924 answers to any question