title: ASP.NET Routing - GetRouteData does not work if path exists
body: <p>I have a <code>HttpModule</code> which intercepts all requests and loads data from the database based on routing rules. However, I run into one problem all the time; <code>GetRouteData</code> only works if the path does not exist:</p>
  
  <pre><code>var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
  </code></pre>
  
  <p>Assuming a request comes in for the url <code>http://localhost/contact</code>, I get the correct routing data relating to that url if that path does not exist in the file system. The problem appears when I want to customize the page at that url which I do by creating an aspx page in the path <code>~/contact/default.aspx</code>. Once I do that, <code>GetRouteData</code> return <code>null</code>.</p>
  
  <p>I have even tried creating a new <code>HttpContext</code> object, but I still can not retrieve route data if the page exists.</p>
  
  <p>Has anyone ever run into this problem? Is there a solution/workaround?</p>
  
  <p>All help will be greatly appreciated.</p>