S
S
Sergey Melnikov2017-10-28 16:28:22
ASP.NET
Sergey Melnikov, 2017-10-28 16:28:22

How to make skip in asp.net mvc routing url check?

Example

routes.MapRoute(
  name: null,
  url: "{slug1}/{slug2}",
  defaults: new { controller = "Home", action = "slug"}
);

routes.MapRoute(
  name: "Default",
  url: "{controller}/{action}",
  defaults: new { controller = "Home", action = "Index" }
);

How to make it so that, for example, when accessing /car/mersedes, the first call is to Action (controller = "Home", action = "slug") , where the database will check for the presence of an article. Further, if not found, then the routing went to Action (defaults: new { controller = "Home", action = "Index" })? That is, later I searched among Controllers and Actions, if I did not find a category / article in the database.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question