Pregunta

I was creating a new action for a WebApi controller and tried to create a url using the following:

@Url.RouteUrl("DefaultApi", new { httproute = "", controller = "ClientApi"})

and noticed that the default route did not have an action attribute, it looks like this:

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

how come the default route doesn't have the action in the route configuration by default? is it bad practice to have it? that is to say is it bad practice to have so many actions in a web api controller that it requires to change the route.

¿Fue útil?

Solución

how come the default route doesn't have the action in the route configuration by default?

Because in REST, the action to be executed by the server is dictated by the HTTP method used in the request.

Licenciado bajo: CC-BY-SA con atribución
scroll top