LoginSignup
1
0

More than 5 years have passed since last update.

IIS ASP.NET ヘッダーからバージョンの削除 

Posted at

環境

windows server 2008 R2
IIS 8.0

Serverを消す

Global.asax.cs
protected void Application_PreSendRequestHeaders(){
    Response.Headers.Remove("Server");
}

X-AspNetMvc-Versionを消す

Global.asax.cs
protected void Application_Start(){
    MvcHandler.DisableMvcResponseHeader = true;
    AreRegistration.RegisterALLAreas();

}

X-AspNet-Versionを消す

Web.config
<system.web>
:
<httpRuntime enableVersionHeader ="false" />
:
</system.web>

X-Powered-Byを消す

Web.config
<system.webServer>
:
<httpProtocol>
 <customHeaders>
  <remove name ="X-Powered-By" /> //addで任意のヘッダを追加できる(X-Frame-Optionsなど)
 </customHeaders>
<httpProtocol>
:
</system.webServer>

反映されない場合はIISを再起動。

HTTP層で管理されているものがGlobal.asax.cs、
Webアプリケーション層で管理されているものがWeb.configを編集
という認識であっているのか...

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0