ASP.NET Core Advanced Series You Don’t Know (3)

ASP.NET Core Advanced Series You Don’t Know (3) Foreword I haven’t updated my blog for more than a year. The last time I wrote about this series was four years ago. Although it’s late, it’s late. There is no commitment. It focuses on casualness, so there is no interruption. Urgent update, haha, in the last article we studied the detailed principles from request to binding, this article discusses the details of model binding. When a problem arises and is finally solved, only by looking back can we analyze its background and design ideas as a whole. gained. Okay, without further ado, let’s start the journey of model binding details. Problem occurs We define a model and then make a query request. Of course, at this time we recommend explicitly using the query feature, that is, FromQuery reception, on the background controller Action method. The code is as follows public class UserAddress { public string span> Code { get; set; } } [ApiController] [Route(” api/[controller]/[action]”)] public class span> UserAddressController : ControllerBase { private readonly span> ILogger _logger; public UserAddressController(ILoggerlogger) { _logger = logger; } [HttpGet] public IActionResult Get( [FromQuery] UserAddress address) { return Ok(address ); } } Nothing wrong, next we…

ASP.NET Core Advanced Series You Don’t Know (3)

ASP.NET Core Advanced Series You Don’t Know (3) Foreword I haven’t updated my blog for more than a year. The last time I wrote about this series was four years ago. Although it’s late, it’s late. There is no commitment. It focuses on casualness, so there is no interruption. Urgent update, haha, in the last article we studied the detailed principles from request to binding, this article discusses the details of model binding. When a problem arises and is finally solved, only by looking back can we analyze its background and design ideas as a whole. gained. Okay, without further ado, let’s start the journey of model binding details. Problem occurs We define a model and then make a query request. Of course, at this time we recommend explicitly using the query feature, that is, FromQuery reception, on the background controller Action method. The code is as follows public class UserAddress { public string span> Code { get; set; } } [ApiController] [Route(” api/[controller]/[action]”)] public class span> UserAddressController : ControllerBase { private readonly span> ILogger _logger; public UserAddressController(ILoggerlogger) { _logger = logger; } [HttpGet] public IActionResult Get( [FromQuery] UserAddress address) { return Ok(address ); } } Nothing wrong, next we…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索