rest - How to create these URLs -
Recover list of seatnames / buses / busnumber / 12 /
GET / Busnumber / 12 / SeatNews - SeatNumber / 5 - Basnambar # 12
Post / Basnumber / 12 / SeatBot # Seats for Recover - Basanambar makes a new seat in # 12 - Pete / Busanumber / 12 / SeatN Box / 5 .... ... ............... .. patch / busnumber / 12 / ctn box / 5 - ................... ... ........
DELETE / Passport / 12 / Citibank / 5 - .......................... ..
Above in ASP.NET Web API2 How to create an appropriate type of URL?
Should this be done through the router configuration? How to add new router without affecting the default router configuration? How can these methods be consumed within the controlling methods?
Thank you, Eric
In Web API 2, you can use the action route Can create attributes and something like this
[Route ("buses / {busnumber} / seat number")] Public enimmereble & lt; Just & gt; GetSeatNumbersByBusNumber (int busNumber) {...} [Route ("buses / {busnumber} / seats / {seatNumber}")) Public enimmereble & lt; Seat & gt; GetSeatsByBusAndSeatNumber (Int busNumber, int seatNumber) {...} You can do this for keep, post, etc.
Web API has more information about the routing feature of 2
To enable routing properties, you have to set Web API config in such a way
Public static zero registration (HTTP configuration configuration) {// Feature routing. Config.MapHttpAttributeRoutes (); // Convention-based routing Config.routes.MapHttpRoute (name: "DefaultApi", Margaemplate: "API / {Administrator} / {ID}", default: new {id = RouteParameter.Optional}); }
Comments
Post a Comment