<?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>Codepolice.net &#187; 404</title>
	<atom:link href="http://codepolice.net/tag/404/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepolice.net</link>
	<description>C#, ASP.NET, MVC, LINQ, Wordpress and stuff like that</description>
	<lastBuildDate>Wed, 01 Sep 2010 08:05:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>404 redirects in code with ASP.NET</title>
		<link>http://codepolice.net/2009/04/14/404-redirects-in-code-with-aspnet/</link>
		<comments>http://codepolice.net/2009/04/14/404-redirects-in-code-with-aspnet/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 14:09:45 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[http-statuscode]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=151</guid>
		<description><![CDATA[I have had problems doing proper 404 redirects in ASP.NET ever since i started to care about proper 404 pages. I do not have any troubles if the page really does not exist. But say for example that i require a querystring on some page and for some reason i do not get a querystring. [...]]]></description>
			<content:encoded><![CDATA[<p>I have had problems doing proper 404 redirects in ASP.NET ever since i <a href="http://googlewebmastercentral.blogspot.com/2008/08/farewell-to-soft-404s.html">started to care about proper 404 pages</a>. I do not have any troubles if the page really does not exist. But say for example that i require a querystring on some page and for some reason i do not get a querystring. Then i guess it&#8217;s proper to give a 404 error.  Today i decided to give it another try and finally i think i have found the solution thanks to two great tips on the amazing Stackoverflow.com.</p>
<p>The first one is that if you want to throw a 404 error you can just do.</p>
<p><strong>throw new HttpException(404, &#8220;Article not found&#8221;);</strong></p>
<p>As simple as that. In almost all other articles i read about this people are talking about doing Response.Status = 404 and stuff like. The problem with that is that the page will continue to execute and you most likley get some kind of error if something vital is missing.</p>
<p>The next thing i learned where that you could do like this.</p>
<div class="codecolorer-container xml twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;</div></div>
<p>Notice the &#8220;redirectMode&#8221; property. It will cause asp.net to not change the url but do a &#8220;Server.Transfer&#8221; like redirect to the error page but keep the URL that thrown the error.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/04/14/404-redirects-in-code-with-aspnet/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! -->