title: ASP.NET CustomError 404
body: <p>So I have basically setup a customError in the web.config which works fine when an exception occurs in the webservice, but now I want to add another customError which will look for an http 404 error. When the webservice gets an exception the ErrorPage.aspx CustomError works fine and when I enter an invalid URL the Yellow Screen Of Death comes up which I don't want, I want the 404.aspx error to come up.</p>
  
  <p>Here is my code for the web.config</p>
  
  <pre><code>&lt;customErrors mode="On" defaultRedirect="~/ErrorPages/ErrorPage.aspx"&gt;
    &lt;error statusCode="404" redirect="~/ErrorPages/404.aspx" /&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>This is the URL that returns when I type in the wrong URL</p>
  
  <pre><code>http://localhost:28745/ErrorPages/404.aspx?aspxerrorpath=/Accounfghogin.aspx
  </code></pre>
  
  <p>And this is the Yellow Screen Of Death I get when typing in the wrong URL</p>
  
  <p>Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's  configuration tag to point to a custom error page URL.</p>