title: Sharepoint 2010 custom 404 page - asp extension
body: <p>I'm working on a SharePoint 2010 publishing site. It's replacing a legacy site built using asp.</p>
  
  <p>As it's public facing and anonymous, we're implementing a custom 404 page. Strangely, this is not simple OOTB (like usual), but I did manage to deploy a 404 page and link it up using an event receiver. Perfect, works fine.</p>
  
  <p>So, in testing I tried entering some random pages that didn't exist. It worked fine for .htm, .html, and .aspx. Next, I tried the .asp extension, as this is what all outstanding bookmarks / search engine links will be based from. Instead of the 404 page I got a blank page. I checked it out in Firebug, and the file was actually returned with a 404 header, but it has no content. Not good.</p>
  
  <p>Anyone solved this problem? Is a custom http module the only way to go here??</p>
  
  <p>As an aside, another strange behaviour is if you use a unknown extension it will render the html from your 404 page as text! <strong>Edit</strong>: Also, if you enter an extensionless folder that doesn't exist you get this same behaviour. Wow, this strange beast continues to vex me.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Looks like a HttpModule is the only way to go here. I have this working - if anyone would like complete code let me know. I'd post it here, but the SO code formatter is mangling things.</p>
  
  <p>web.config entry looks like the following:</p>
  
  <pre><code>&lt;add name="PageNotFoundHttpModule" type="ProjectName.PageNotFoundHttpModule, ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fb507da11a891ef3" preCondition="integratedMode" /&gt; 
  </code></pre>