title: How to return 'own' 404 custom page?
body: <p>In case if error occurred on my web site I do the following:</p>
  
  <pre><code>        Server.Transfer("/error.aspx");
  </code></pre>
  
  <p>and that page has code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      ...
  
      Response.StatusCode = 404;
  }
  </code></pre>
  
  <p>If I work on the localhost then together with 404 status returned for the page, page displays 'proper error description'. </p>
  
  <p>Once I published the same code to the internet all pages with errors are still displayed with 404 status code, but the don't have the content. Instead, they have the standard 404 error message:</p>
  
  <blockquote>
    <p>404 - File or directory not found.</p>
  </blockquote>
  
  <p>if the line "Response.StatusCode = 404" commented out then the proper page is provided, but it has 200 status code.</p>
  
  <p><strong>Question:</strong> how to return user-friendly error page that in the same time has 404 error status code?</p>
  
  <p>Any thoughts are welcome! Thanks a lot in advance!</p>
  
  <p>P.S. ASP.NET 4.0</p>