public
Created

  • Download Gist
QueryPropagatingRoute.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.