Вопрос

I have a question about MVC routing. Given the route:

routes.MapRoute(
    name: "Venda",
    url: "{controller}/{action}/{automovelId}/{consumidorId}/{revendedoraId}",
    defaults: new {
        controller = "Venda",
        action = "Index",
        automovelId = UrlParameter.Optional,
        consumidorId = UrlParameter.Optional,
        revendedoraId = UrlParameter.Optional
    }
);

I want to be able to call the Edit action like this:

/Venda/Edit/1/1/1

But it only works when called like this:

/Venda/Edit?automovelId=1&consumidorId=1&revendedoraId=1

How can I do this?

Это было полезно?

Решение

You cant use multiple optional parameters in a route. Only the last parameter can be optional.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top