c# - Syntactic sugar in Web Api - how to omit [FromBody] -


is possible omit writing [frombody]?

[httppost] public string somemethod([frombody]somemodel model) {     return "ok"; } 

should apply global attribute? how achieve this?

the model binding attributes in mvc 5 specify "bindingsource" each parameter on action , can specify each property on controller, too. can see code picks frombody attribute in bodymodelbinder

let me first should beware of beta6 (and think point in beta5), having multiple parameters/properties bindingsource.body not allowed, , not able use actions if have multiple parameters left default. might desirable if want annotate more; guess not.

you can see in defaultapidescriptionprovider default source set; unfortunately, there no hook @ point tie into, , method private , not virtual; you'll need re-implement entire class.

once have, though, it's rather easy register in configureservices use instead:

services.tryadd(servicedescriptor.transient<iapidescriptionprovider, yourapidescriptionprovider>()); 

you can see the default being registered in source, too.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -