I have a HttpModule
which intercepts all requests and loads data from the database based on routing rules. However, I run into one problem all the time; GetRouteData
only works if the path does not exist:
var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
Assuming a request comes in for the url http://localhost/contact
, 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 ~/contact/default.aspx
. Once I do that, GetRouteData
return null
.
I have even tried creating a new HttpContext
object, but I still can not retrieve route data if the page exists.
Has anyone ever run into this problem? Is there a solution/workaround?
All help will be greatly appreciated.