inheritance - How can I provide methods in a base web api controller that can be accessed via attribute routing -


base class:

public class dataapicontrollerbase<t> : apicontroller     {         public list<validationresult> validate(t input)         {             ...          }     } 

derived class:

public class customercontroller: dataapicontrollerbase<customer>     {         [route("api/customer/{id}")]         public customer get([fromuri] guid id)        {         }      } 

what route resolve "validate" endpoint on each derived controller endpoint? right way go this?

i'd use method override solve this

base class

public class dataapicontrollerbase<t> : apicontroller {     public virtual list<validationresult> validate(t input)     {         ...      } } 

derived class

public class customercontroller: dataapicontrollerbase<customer> {     route("api/customer/validate")]     [httppost]     public override list<validationresult> validate(customer input)     {         base.validate(input);     }     route("api/customer/{id}")]    public customer get([fromuri] guid id)    {     } }    

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 -