title: ASP.net 404 redirect to homepage
body: <p>I am new to ASP.net.
  I have set up Google analytics and Webmaster Tools for my example.com site.
  WMT gives a list of 404 URLs for my site.</p>
  
  <p>I use following code to redirect to my homepage if the URL ends with <code>.aspx</code>, but if the URL ends with <code>.asp</code>, it's not working.</p>
  
  <pre><code>void Application_Error(object sender, EventArgs e) 
  { 
  
      HttpException httpException = Server.GetLastError() as HttpException;
      if (httpException.GetHttpCode() == 404)
          Response.Redirect("/");
  }
  </code></pre>