Skip to content
Create a gist now

Instantly share code, notes, and snippets.

private class QueryPropagatingRoute : RouteBase {
private readonly RouteBase target;
private readonly string[] queryStringKeys;
public QueryPropagatingRoute(RouteBase target, params string[] queryStringKeys) { = target;
this.queryStringKeys = queryStringKeys;
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) {
foreach (var key in this.queryStringKeys) {
if (values.ContainsKey(key))
values.Add(key, requestContext.HttpContext.Request.QueryString[key]);
var path = target.GetVirtualPath(requestContext, values);
return path;
public override RouteData GetRouteData(HttpContextBase httpContext) {
return target.GetRouteData(httpContext);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.