I've been on this almost 2 days and I'm really feeling stuck. I've been running a site for a few years using MapPageRoute to create urls for several hundred "pages" that are all handled by "~/default.aspx" via database lookups for page data. The entire site is not like this (i.e. it's not a single page site), but a good portion is.
It has been working fine except I am unable to use querystrings on the mapped routes. The RegisterRoutes method in the global.asax is:
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
routes.Ignore("{resource}.ashx/{*pathInfo}"); //ignore ashx files
routes.Ignore("{resource}.axd/{*pathInfo}"); //ignore axd files, prevents javascript/routing collisions
routes.MapPageRoute("SitePage", "{*page_url}", "~/default.aspx", false);
}
I use a wildcard on the path segment. Unfortunately only one wildcard is allowed. {*page_url} typically represents 1 to 4 segments. I've tried various forms of IRouteHandler and IHttpHandler code, but I don't see how to change the url that appears in the client browser. I can use the wildcard this way because none of the routes interfere with a physical files.
The only reason I want to preserve the querystring is because Google Adwords adds on a ?gclid=xxxxxxxxx string to an ad link, and Google Analytics .js uses that querystring to report back.
A sample URL depiction of the issue is:
/about-us/community/philanthropy (resolves fine)
/about-us/community/philanthropy?gclid=xxxxxxx (redirects back to:)
/about-us/community/philanthropy
My web.config is free of url-rewriting settings that might affect this.
A fair amount of my research on SO and elsewhere is for MVC sites. This is a WebForms site.
Example, similar question, but for MVC: How do I route a URL with a querystring in ASP.NET MVC?