我正在为我的业务构建一个REST API,我需要从请求中的标头中获取值,但我不知道怎么办?
我需要在标题中创建一个过滤器并对此进行验证。
这样的标题:header:filterDate = false / true
public CarrierController(ICarrierAppService appService, ICarrierEAppService EAppService)
{
_appService = appService;
_EAppService = EAppService;
}
/// <summary>
/// Create or update a carrier
/// </summary>
/// <param name="messageUniqueId">Message Id from external system </param>
/// <param name="carrierDto">Carrier to create</param>
/// <returns>Carrier created or updated</returns>
[HttpPost]
[ProducesResponseType (typeof (CarrierDto), 200)]
[ProducesResponseType (typeof (ErrorResponse), 400)]
public async Task<IActionResult> Post (bool isBusinessE, string messageUniqueId, [FromBody] CarrierDto carrierDto) {
carrierDto = await _EAppService.UpsertCarrierAsync (carrierDto);
return CreateResponseOnPost (carrierDto, _name);
}
请帮助我升级:'/我只是一个小菜鸟:'/
在名为的方法内Post
,您可以使用Request.Headers
字典对象访问请求的标头。例如:Request.Headers["filterDate"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句