c# - asp.net web api attribute routing -


api

[routeprefix("api/diagnostics")] public class diagnosticscontroller : apicontroller {     [httppost]     [route("pings")]     public ihttpactionresult pings(ping ping)     {      } } 

ping

public class ping {    public guid serverkey {get;set;}    public datetime createddatetime {get;set;} } 

i trying test class using postman application. here screenshot.

the message is:

{ "message": "no http resource found matches request uri 'http://localhost:61668/api/diagnostics/pings'.", "messagedetail": "no action found on controller 'diagnostics' matches request." } 

i failing understand why not match post action in diagnostics controller. other route configured default route:

 config.routes.maphttproute(                 name: "defaultapi",                 routetemplate: "api/{controller}/{key}",                 defaults: new { key = routeparameter.optional }             ); 

also attribute routing enabled: config.maphttpattributeroutes();

try mark parameter [frombody] attribute - public ihttpactionresult pings([frombody] ping ping).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -