A
A
addd2015-11-30 12:41:33
ASP.NET
addd, 2015-11-30 12:41:33

How to make the right route?

There is a controller with an index method that takes 3 parameters.
routes.MapRoute("Home", "{link}/{sublink}/{filter}", MVC.Home.Index()
.AddRouteValue("link", UrlParameter.Optional)
.AddRouteValue("sublink", UrlParameter.Optional )
.AddRouteValue("filter", UrlParameter.Optional));
How to make a route?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2015-11-30
@dmitryKovalskiy

1) If it MANDATORY takes 3 parameters - throw out the block

.AddRouteValue("link", UrlParameter.Optional)
.AddRouteValue("sublink", UrlParameter.Optional)
.AddRouteValue("filter", UrlParameter.Optional));

2) The basis of routing is not your parameters, but controller and action. Who will actually handle your request.
I don't see how the pointing to the controller happens.
3) there is such a record
context.MapRoute(
                "AreaName_default",
                "AreaName/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }, namespace где ищем контроллеры" }
            );

Here 1 call to MapRoute is made. You have added 3 extra calls. What for? Space to save?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question