Specifying custom property name when binding object to Web API endpoint

前端 未结 7 875

I have a .Net Core Web API. It automatically maps models when the model properties match the request body. For example, if you have this class:

public clas         


        
相关标签:
7条回答
  • 2020-12-09 16:06

    I think that this should work too:

    using Microsoft.AspNetCore.Mvc;
    public class Package
    {
         [BindProperty(Name ="carrier")]
         public string Carrier { get; set; }
    
         [BindProperty(Name ="trackingNumber")]
         public string TrackingNumber { get; set; }
    }
    
    0 讨论(0)
提交回复
热议问题