title: Why setting customErrors in web.config doesn't work at this case?
body: <p>In my ASP.NET 3.5 Website which is published in shared hosting provider , I've configured my web.config file like this :</p>
  
  <pre><code>    &lt;customErrors mode="On" defaultRedirect="GenericErrorPage.htm"&gt;
          &lt;error statusCode="403" redirect="AccessDenied.htm"/&gt;
          &lt;error statusCode="404" redirect="FileNotFound.htm"/&gt;
      &lt;/customErrors&gt;
  </code></pre>
  
  <p>If the user request pages that doesn't exist ( like "www.example.com/NotExistPage.aspx" ) , user will be redirected to FileNotFound.htm page as we expect .</p>
  
  <p>But if the user request some address like : "www.example.com/NotExistDirectory" without .aspx extension , the user will encounter IIS 7.5 Error page  :</p>
  
  <blockquote>
    <p>HTTP Error 404.0 - Not Found The
    resource you are looking for has been
    removed, had its name changed, or is
    temporarily unavailable.</p>
  </blockquote>
  
  <p>Detialed error information : </p>
  
  <pre><code>Module  IIS Web Core
  Notification    MapRequestHandler
  Handler StaticFile
  Error Code  0x80070002
  
  Requested URL   http://www.example.com:80/NotExistDirectory
  Physical Path   D:\Websites\example\example.com\wwwroot\NotExistDirectory
  Logon Method    Anonymous
  Logon User  Anonymous
  </code></pre>
  
  <p>This is a yellow page which is not user friendly and we didn't expect . </p>
  
  <p>I'm wondering setting customeError in webconfig doesn't support this type of address or not ? How can i prevent users seeing this yellow page . </p>
  
  <p><strong>Edit :</strong> 
  Thanks to David's answer , But I found the actual reason and correct solution. Please see my answer.</p>