6

ASP.NET 4.5アプリが共有ホスティングに展開されているため、IIS設定にアクセスできません。X-Powered-Byヘッダーを削除するには、次のように指定しweb.configます。

<system.webServer>
  <httpProtocol>
    <customHeaders>
      <remove name="X-Powered-By" />
    </customHeaders>
  </httpProtocol>
</system.webServer>

そして、Serverヘッダーを削除するには、次のように指定しますGlobal.asax

protected void Application_PreSendRequestHeaders(object sender, EventArgs e) {
  HttpContext.Current.Response.Headers.Remove("Server");
}

ただし、応答には引き続き両方のヘッダーが含まれます。

Cache-Control:private
Content-Encoding:deflate
Content-Length:672
Content-Type:text/html; charset=utf-8
Date:Sun, 06 Jan 2013 00:41:20 GMT
Server:Microsoft-IIS/7.5
X-Powered-By:ARR/2.5
X-Powered-By:ASP.NET

どうすれば削除できますか?

4

4 に答える 4

0

IIS 7 を使用している場合、Global.asax でDisableMvcResponseHeaderプロパティを true に設定すると、「X-Powered-By」ヘッダーが削除されます。

protected void Application_Start()
{
    MvcHandler.DisableMvcResponseHeader = true;
}
于 2013-01-06T01:42:33.203 に答える