使用 HttpResponseMessage 作为Get操作的返回类型的默认行为如下所示:
HTTP/1.1 200 OK
Content-Length: 10
Content-Type: text/plain; charset=utf-16
Server: Microsoft-IIS/8.0
Date: Mon, 27 Jan 2014 08:53:35 GMT
<my data>
我想要的是对响应中的哪个http标头进行完整控制。
答案 0 :(得分:2)
ApiController类中的默认Get方法:
[HttpGet]
public HttpResponseMessage Ping()
{
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("X-Custom-Header", "This is my custom header.");
response.Headers.Remove("Server");
return response;
}