title: IIS always change a 403 to 404 Error
body: <p>I am having a strange problem, i have written a code for 403 Error in Application_Error Event in Global.asax file. What this code does it replaces .asp extension with .aspx here is the code </p>
  
  <pre><code>HttpException serverError = Server.GetLastError() as HttpException;
  if (null != serverError)
  {
      int errorCode = serverError.GetHttpCode();
      if (404 == errorCode)
      {
          Server.ClearError();
          Server.Transfer("Error.aspx");
      }
      if (403 == errorCode)
      {
          Response.Redirect(Request.Url.ToString().Replace(".asp", ".aspx"));
      }
  }
  </code></pre>
  
  <p>it works fine on localhost but on IIS when i type Default.asp Page it gives me 404 error. and another issue is that i have created an Error Page. but it only shows Error page for .aspx pages. any ideas, please?</p>
  
  <p>URL rewrite module which i tried is </p>
  
  <pre><code>&lt;rewrite&gt;
        &lt;rules&gt;
          &lt;rule name="aspToASPNET"&gt;
            &lt;match url="^(.*).asp$" /&gt;
            &lt;action type="Rewrite" url="{R:1}.aspx" /&gt;
          &lt;/rule&gt;
        &lt;/rules&gt;
      &lt;/rewrite&gt;
  </code></pre>