public virtual void PostResolveRequestCache (HttpContextBase context)
{
if (context == null)
throw new ArgumentNullException ("context");
var rd = RouteCollection.GetRouteData (context);
if (rd == null)
return; // do nothing
if (rd.RouteHandler == null)
throw new InvalidOperationException ("No IRouteHandler is assigned to the selected route");
if (rd.RouteHandler is StopRoutingHandler)
return; //stop further processing
var rc = new RequestContext (context, rd);
IHttpHandler http = rd.RouteHandler.GetHttpHandler (rc);
if (http == null)
throw new InvalidOperationException ("The mapped IRouteHandler did not return an IHttpHandler");
#if NET_4_0
context.Request.RequestContext = rc;
context.RemapHandler (http);
#else
// note: It does not resolve paths using GetVirtualPath():
//var vpd = RouteCollection.GetVirtualPath (rc, rd.Values);
//context.RewritePath (vpd.VirtualPath);
context.Items [original_path_key] = context.Request.Path;
// default handler (forbidden in MVC/DynamicData projects)
context.RewritePath ("~/UrlRouting.axd");
context.Items [module_identity_key] = http;
#endif
}
}