yönlendirme ASP.net MVC 4 WebAPI içinde yuvalanmış kaynaklarını ele bu şekilde DİNLENME API sağlamak istiyorum:Düzgün
GET /api/devices
POST /api/devices
PUT /api/devices/1
DELETE /api/devices/1
Bu benim yapılandırma:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Ve bunlar Eylemler:
vb. İç içe kaynağa GET ve POST çalışırken
config.Routes.MapHttpRoute(
name: "NestedApi",
routeTemplate: "api/{controller}/{parentResourceId}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
sorunu gösterir:
GET /api/devices/1/readings
POST /api/devices/1/readings
GET /api/devices/1/readings/1
PUT /api/devices/1/readings/1
DELETE /api/devices/1/readings/1
Bu, bu benim Configration: Ben iç içe kaynakları işlemek istediğinizde
sorunu görünür :
[HttpGet]
public String Readings(int parentResourceId)
{
//return a list of readings for the device
}
[HttpPost]
public String Readings(int parentResourceId)
{
//create and return the id of a reading for the device
}
Bu, tabi ki başarısız oluyor çünkü iki eylem var. aynı imza.
Ben en çok dinlendirici bir yaklaşım
Bu, bir http://stackoverflow.com/q/10783946/326110 ve http://stackoverflow.com/questions/9594671/nested-resources-in-asp-net-mvc-4-webapi kopyası gibi görünüyor./16094056 # 16094056 –