Add a custom response header in ApiController

后端 未结 6 1708
难免孤独
难免孤独 2021-02-05 02:41

Until now, I had a GET method that looked like the following:

protected override async Task GetAll(QueryData query)
{
              


        
6条回答
  •  爱一瞬间的悲伤
    2021-02-05 02:59

    What you need is:

    public async Task Get() 
    { 
        var response = Request.CreateResponse();
        response.Headers.Add("Lorem", "ipsum");
    
        return base.ResponseMessage(response); 
    }
    

    I hope this answers your question.

提交回复
热议问题