Skip to content

Commit 6350570

Browse files
Remove unnecessary HTTP response headers
This removes: X-AspNetMvc-Version: 4.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET I didn't see any performance improvement, but this is probably a good idea in case the extra bytes cause another network packet to be needed, compared to other frameworks.
1 parent c31b4dc commit 6350570

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

aspnet/src/Application.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public void Init(HttpApplication context)
2323

2424
private void Start()
2525
{
26+
// Remove X-AspNetMvc-Version HTTP response header
27+
MvcHandler.DisableMvcResponseHeader = true;
2628
Routes();
2729
Views();
2830
}

aspnet/src/Web.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
</providers>
2727
</entityFramework>
2828
<system.web>
29+
<!-- Remove X-AspNet-Version HTTP response header -->
30+
<httpRuntime enableVersionHeader="false" />
2931
<!-- Show errors -->
3032
<customErrors mode="Off"/>
3133
</system.web>

installer.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ appcmd set config -section:system.webServer/httpErrors -errorMode:Detailed | Out
2626
# Disable logging
2727
appcmd set config -section:system.webServer/httpLogging -dontLog:True | Out-Null
2828

29+
# Remove unnecessary X-Powered-By HTTP response header
30+
appcmd set config -section:system.webServer/httpProtocol /-"customHeaders.[name='X-Powered-By']" | Out-Null
31+
2932
# URL Rewrite
3033
$rewrite_url = "http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi"
3134
$rewrite_local = "$workdir\rewrite_2.0_rtw_x64.msi"

0 commit comments

Comments
 (0)