Created
February 26, 2012 20:42
-
-
Save ashmind/1918893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class QueryPropagatingRoute : RouteBase { | |
private readonly RouteBase target; | |
private readonly string[] queryStringKeys; | |
public QueryPropagatingRoute(RouteBase target, params string[] queryStringKeys) { | |
this.target = target; | |
this.queryStringKeys = queryStringKeys; | |
} | |
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) { | |
foreach (var key in this.queryStringKeys) { | |
if (values.ContainsKey(key)) | |
continue; | |
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