Skip to main content

removing unnecessary http headers in iis and asp.net

Server Headers:

To remove Server headers there are multiple solutions
Solution 1:
Add the below code snippet in global.asax file
protected void Application_PreSendRequestHeaders()
        {
            Response.Headers.Remove("Server");
        }

Solution 2: (Preferred)
Download and install the latest version of urlscan tool (version 3.1) from the following link
32-Bit (x86):
64-Bit (x64):
After installing goto below location
C:\Windows\System32\inetsrv\urlscan
Open “UrlScan.ini” file in notepad as a Administrator

Update the value for RemoveServerHeader=1 from 0.

X-Powered-By Headers:

Solution 1:
Remove the X-Powered-By headers from IIS
Open IIS

Click on required website
Click on HTTP Response headers,
Right click on “X-Powered-By” and remove the header by clicking Yes
Solution 2:
Including the below lines to the <system.webServer> element of web.config
<httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
      </customHeaders>
</httpProtocol>

 X-AspNet-Version:
Solution 1:
In web.config add this under System.Web
<httpRuntime enableVersionHeader="false"/>

Solution 2:
Add the below code snippet in global.asax file
protected void Application_PreSendRequestHeaders()
        {
            Response.Headers.Remove("X-AspNet-Version ");
        }

Comments

Popular posts from this blog

how to integrate kendo ui in asp.net mvc

Introduction: Here I am going to explain how to integrate Kendo to MVC5. I have developed this project by taking reference by this link http://docs.telerik.com/aspnet-mvc/getting-started/asp-net-mvc-5 Before integration, let’s be ready with Kendo UI stuff. Check in your machine, whether “ui-for-asp.net-mvc” installed or not. See the below screen shot If it is not there, then follow the below steps to install it. Step 1: Goto https://www.telerik.com/account/ If you don’t have account, you can create for trail account. Step 2: Paste the below link in browser once you have logged in https://www.telerik.com/download-trial-file/v2/ui-for-asp.net-mvc it will ask download location for software. It looks like below Once after completion of the software, install it. Now we are ready with all the files required for integration of Kendo with MVC. Follow the steps below Step 1: Open visual studio, sele

implement hsts iis

We can implement HSTS using multiple approaches. Approach 1: PRE-REQUISITES: URL Rewrite module has to be installed from the below link https://www.microsoft.com/en-in/download/details.aspx?id=7435 Add the below code to web.config <?xml version= "1.0" encoding= "UTF-8" ?> <configuration>     <system.webServer>         <rewrite>             <rules>                 <rule name = "HTTP to HTTPS redirect" stopProcessing = "true" >                     <match url = "(.*)" />                     <conditions>                         <add input = "{HTTPS}" pattern = "off" ignoreCase = "true" />                     </conditions>                     <action type = "Redirect" url = "https://{HTTP_HOST}/{R:1}"                         redirectType = "Permanent" />