<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Frederik Vig - ASP.NET developer &#187; IIS</title>
	<atom:link href="http://www.frederikvig.com/category/iis/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederikvig.com</link>
	<description></description>
	<lastBuildDate>Wed, 28 Dec 2011 23:33:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Removing HTTP Headers for ASP.NET sites</title>
		<link>http://www.frederikvig.com/2010/11/removing-http-headers-for-asp-net-sites/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-http-headers-for-asp-net-sites</link>
		<comments>http://www.frederikvig.com/2010/11/removing-http-headers-for-asp-net-sites/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 10:02:38 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Umbraco]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1447</guid>
		<description><![CDATA[By default IIS and ASP.NET add a couple informational HTTP Headers to a response. They add extra traffic and give away security information like ASP.NET version, IIS version etc. To see the HTTP Header you can use a proxy tool like Fiddler or Live HTTP Header. The example below is for a regular ASP.NET site. ...]]></description>
			<content:encoded><![CDATA[<p>By default IIS and ASP.NET add a couple informational HTTP Headers to a response. They add extra traffic and give away security information like ASP.NET version, IIS version etc. To see the HTTP Header you can use a proxy tool like Fiddler or Live HTTP Header. The example below is for a regular ASP.NET site.</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/http-headers/http-headers.png" alt="HTTP Header for a typical ASP.NET site" />
</p>
<h3>Removing the X-Powered-By Header</h3>
<p>Open up IIS Manager, choose your site and go to HTTP Response Headers. Here you&#8217;ll see X-Powered-By being inherited. You can either remove it only for this site or for all sites on this server (select the server name in IIS Manager and HTTP Response Headers).</p>
<p>You can also do this in your sites web.config.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;</span><span style="color: #000000;">system</span><span style="color: #008000;">.</span><span style="color: #0000FF;">webServer</span><span style="color: #008000;">&gt;</span>
<span style="color: #008000;">...</span>
<span style="color: #008000;">&lt;</span>httpProtocol<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>customHeaders<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>remove name<span style="color: #008000;">=</span><span style="color: #666666;">&quot;X-Powered-By&quot;</span> <span style="color: #008000;">/&gt;</span>
    <span style="color: #008000;">&lt;/</span>customHeaders<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>httpProtocol<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">...</span>
<span style="color: #008000;">&lt;/</span><span style="color: #000000;">system</span><span style="color: #008000;">.</span><span style="color: #0000FF;">webServer</span><span style="color: #008000;">&gt;</span></pre>
</div>
</div>
<h3>Removing the Server Header</h3>
<p>To remove this HTTP Header we need to create a custom HTTP Module.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> MyNamespace
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> HttpHeadersCleanup <span style="color: #008000;">:</span> IHttpModule
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Init<span style="color: #008000;">&#40;</span>HttpApplication context<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            context<span style="color: #008000;">.</span><span style="color: #0000FF;">PreSendRequestHeaders</span> <span style="color: #008000;">+=</span> PreSendRequestHeaders<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> PreSendRequestHeaders<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Server&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Dispose<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre>
</div>
</div>
<p>You also need to register the HTTP Module in your sites web.config.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules</span> <span style="color: #000066;">runAllManagedModulesForAllRequests</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;HttpHeadersCleanup &quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;MyNamespace.HttpHeadersCleanup, MyAssembly&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
<h3>Removing the ETag Header</h3>
<p>For more information on ETag see: <a href="http://en.wikipedia.org/wiki/HTTP_ETag">HTTP ETag</a>.</p>
<p>To remove ETag you need to add the code below to the HTTP Module described previously.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;">HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ETag&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<h3>Removing the X-Aspnet-Version Header</h3>
<p>To remove this HTTP Header you simply set enableVersionHeader to false in your sites web.config.</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;</span><span style="color: #000000;">system.<span style="color: #0000FF;">web</span></span><span style="color: #008000;">&gt;</span>
<span style="color: #008000;">...</span>
    <span style="color: #008000;">&lt;</span>httpRuntime enableVersionHeader<span style="color: #008000;">=</span><span style="color: #666666;">&quot;false&quot;</span> <span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">...</span>
<span style="color: #008000;">&lt;/</span><span style="color: #000000;">system.<span style="color: #0000FF;">web</span></span><span style="color: #008000;">&gt;</span></pre>
</div>
</div>
<p>Or by removing it in the HTTP Module:</p>
<div class="wp_syntax">
<div class="code">
<pre class="csharp" style="font-family:monospace;">HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;X-AspNet-Version&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre>
</div>
</div>
<p>Here&#8217;s how the HTTP Headers look now:</p>
<p>
<img src="http://www.frederikvig.com/wp-content/uploads/http-headers/new-http-headers.png" alt="New HTTP Headers after removing X-Powered-By Header, Server, and ETag" />
</p>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/04/detecting-ajax-requests-on-the-server/" rel="bookmark" title="April 6, 2010">Detecting Ajax requests on the server</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/" rel="bookmark" title="October 9, 2011">Faster EPiServer sites &#8211; client side performance</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/02/getting-the-page-and-episerver-currentpage-object-from-httpcontext/" rel="bookmark" title="February 20, 2010">Getting the Page and EPiServer CurrentPage object from HttpContext</a></li>
</ul>
<p><!-- Similar Posts took 65.871 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/11/removing-http-headers-for-asp-net-sites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Specify a canonical domain name for your site with IIS 7</title>
		<link>http://www.frederikvig.com/2010/07/specify-a-canonical-domain-name-for-your-site-with-iis-7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=specify-a-canonical-domain-name-for-your-site-with-iis-7</link>
		<comments>http://www.frederikvig.com/2010/07/specify-a-canonical-domain-name-for-your-site-with-iis-7/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:57:17 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1312</guid>
		<description><![CDATA[When setting up new sites in IIS you specify which host names map to your site. Usually this is at least two: www.example.com and example.com, sometimes even more. One great new addition to IIS 7 is the URL Rewriting extension. This allows you to setup a few rules for your URLs. Let&#8217;s start by downloading ...]]></description>
			<content:encoded><![CDATA[<p>When setting up new sites in IIS you specify which host names map to your site. Usually this is at least two: www.example.com and example.com, sometimes even more. One great new addition to IIS 7 is the URL Rewriting extension. This allows you to setup a few rules for your URLs.</p>
<p>Let&#8217;s start by downloading and installing the URL Rewrite extension. The <a href="http://iis.net">official IIS site</a> has a <a href="http://www.iis.net/download">download section</a> with some very cool extension that I recommend you check out when you have the time. For now we only need the <a href="http://www.iis.net/download/URLRewrite">URL Rewrite extension</a>. This will launch the Web Platform Installer, click Install and Accept. You should now see a new module in IIS. </p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/canonical-domain/iis-url-rewrite.png" alt="URL Rewrite extension in IIS 7" /></p>
<p>To setup the rule we need for our canonical domain, just click the Add Rule(s) link and and under Search Engine Optimization (SEO) section choose Canonical domain name. Select a primary host name and you&#8217;re done!</p>
<p><img src="http://www.frederikvig.com/wp-content/uploads/canonical-domain/add-rule-iis-url-rewrite.png" alt="Choose primary host name during Add rule with IIS URL Rewrite" /></p>
<p>What this does is redirect all traffic going to www.frederikvig.com to frederikvig.com,  www.frederikvig.com/news to frederikvig.com/news etc, with a 301 (permanent redirect). </p>
<p>The reason this is important for SEO purposes is that search engines treat all URLs differently, so when you have two or more URLs all pointing to the same content your search ranking will suffer. Fortunately we have fixed this now with this rule, next time Google or some other search engine visits your site it will update it&#8217;s indexes, making all links point to the same domain name.</p>
<p>There are a lot of other great enhancements (Enforce lowercase URLs, User Friendly URLs etc) that I recommend checking out. Here are <a href="http://learn.iis.net/tags/URL+Rewrite+Module/default.aspx">a few articles</a> to get you started.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/11/specify-your-preferred-external-url-in-episerver/" rel="bookmark" title="November 7, 2009">Specify your preferred external URL in EPiServer</a></li>
<li><a href="http://www.frederikvig.com/2011/03/links-for-episerver-developers-2/" rel="bookmark" title="March 12, 2011">Links for EPiServer Developers &#8211; #2</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-7-creating-the-sitemap-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 22, 2009">Part 7: Creating the Sitemap page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/06/using-multiple-forms-on-an-asp-net-web-forms-page/" rel="bookmark" title="June 21, 2009">Using multiple forms on an ASP.NET web forms page</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
</ul>
<p><!-- Similar Posts took 35.362 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/07/specify-a-canonical-domain-name-for-your-site-with-iis-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
