c# - Implicit Verbs from Method name -


if create webapi controller, , populate methods prefixed http verbs, api able correctly imply verb should used on controller.

public class testcontroller : apicontroller {     public string getdata()     {         return "called method";     }      public string postdata()     {         return "called post method";     }      public string putdata()     {         return "called put method";     } } 

if replace post update, post method continues work implicitly.

public string updatedata() {     return "called updated method"; } 

is there list of possible prefixes on method , verb map to? additionally, possible define custom prefixes? instance, if wanted map method starting "search" post, can define this?

if put routing following :

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

consider routetemplate.you'll able call actions on controller name,and no prefix issue should exist. approach helpful if have multiple actions on controller similar http verbs(multiple get or post say).


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -