System.Web.Routing.UrlRoutingModule.PostResolveRequestCache C# (CSharp) Method

PostResolveRequestCache() private method

private PostResolveRequestCache ( HttpContextBase context ) : void
context HttpContextBase
return void
		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
		}
	}

Same methods

UrlRoutingModule::PostResolveRequestCache ( object o, EventArgs e ) : void

Usage Example

		public virtual void PostResolveRequestCache(HttpContextBase context)
		{
			var request = context.Request;
			if (request == null || _routes.Count == 0)
				return;

			var path = request.AppRelativeCurrentExecutionFilePath.TrimStart('~').TrimEnd('/');
			var method = request.HttpMethod.EmptyNull();

			foreach (var route in _routes)
			{
				if (route.PathPattern.IsMatch(path) && route.HttpMethodPattern.IsMatch(method))
				{
					var module = new UrlRoutingModule();
					module.PostResolveRequestCache(context);
					return;
				}
			}		
		}
All Usage Examples Of System.Web.Routing.UrlRoutingModule::PostResolveRequestCache