<?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>#if debug &#187; ASP.NET</title>
	<atom:link href="http://ifdebug.com/tag/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://ifdebug.com</link>
	<description>Technical thoughts of a coffee addicted developer</description>
	<lastBuildDate>Fri, 16 Sep 2011 13:18:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>ASP.NET Permanent (301) Redirect</title>
		<link>http://ifdebug.com/aspnet-permanent-301-redirect/</link>
		<comments>http://ifdebug.com/aspnet-permanent-301-redirect/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 13:07:05 +0000</pubDate>
		<dc:creator>Alistair</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[permanent redirect]]></category>

		<guid isPermaLink="false">http://ifdebug.com/?p=49</guid>
		<description><![CDATA[Within ASP.NET, the System.Web.HttpResponse class providers a method to handle HTTP redirects, aptly named Redirect. The Redirect method has two overloads: Redirect (string) Redirect (string, bool) The former accepts a string representation of the URI that you&#8217;d like to redirect &#8230; <a href="http://ifdebug.com/aspnet-permanent-301-redirect/">Continue reading <span class="meta-nav">&#8594;</span></a>


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Within ASP.NET, the <a href="http://msdn2.microsoft.com/en-us/library/system.web.httpresponse.aspx"><code>System.Web.HttpResponse</code></a> class providers a method to handle HTTP redirects, aptly named <a href="http://msdn2.microsoft.com/en-us/library/system.web.httpresponse.redirect.aspx"><code>Redirect</code></a>. The <code>Redirect</code> method has two overloads:</p>
<ul>
<li><code>Redirect (string)</code></li>
<li><code>Redirect (string, bool)</code></li>
</ul>
<p>The former accepts a string representation of the URI that you&#8217;d like to redirect to. The latter accepts the string URI and a boolean indicating whether you want ASP.NET to stop processing the request immediately or to continue throughout the life cycle of the request.</p>
<p>Unless you&#8217;re a HTTP junkie or you&#8217;ve had a specific reason to issue a permanent redirect (reorganising a web site is a prime candidate), you can be forgiven for not realising that the <code>Redirect</code> method issues a temporary redirect (HTTP 302). Not having needed to issue a permanent redirect through ASP.NET before, I assumed (there is that word again) that there would be additional overloads to handle both temporary (HTTP 302) and permanent (HTTP 301) redirects or optionally another method; I was wrong.</p>
<p>To issue a HTTP 301 permanent redirect through ASP.NET, you need to do a little bit of manual labour; don&#8217;t worry it&#8217;s only two lines of code:</p>
<ul>
<li><code>Response.Status = "301 Permanently Moved";</code></li>
<li><code>Response.AppendHeader ("Location", URI);</code></li>
</ul>
<p>At this point, so long as nothing else interferes with the response &#8211; the client will receive a standard run of the mill 301 HTTP permanent redirect. If you know or are worried that something following the above lines may modify the response, you can issue an optional <code>Response.End()</code> as the third line to make it take effect immediately.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://ifdebug.com/aspnet-permanent-301-redirect/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

