[英]How can I control the HTTP response headers added to my ASP.NET core web application when hosted in Azure app service?
[英]How can I get a full control over the HTTP headers in ASP.Net WebAPI 2?
使用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標頭。
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.