internal void DoPostResolveRequestCache(HttpContextBase context) { if (IsExplicitlyDisabled) { // If the root config is explicitly disabled, do not process the request. return; } // Parse incoming URL (we trim off the first two chars since they're always "~/") string requestPath = context.Request.AppRelativeCurrentExecutionFilePath.Substring(2) + context.Request.PathInfo; string[] registeredExtensions = WebPageHttpHandler.SupportedExtensions; // Check if this request matches a file in the app WebPageMatch webpageRouteMatch = MatchRequest(requestPath, registeredExtensions, VirtualPathFactoryManager.InstancePathExists, context, DisplayModeProvider.Instance); if (webpageRouteMatch != null) { // If it matches then save some data for the WebPage's UrlData context.Items[typeof(WebPageMatch)] = webpageRouteMatch; string virtualPath = "~/" + webpageRouteMatch.MatchedPath; // Verify that this path is enabled before remapping if (!WebPagesDeployment.IsExplicitlyDisabled(virtualPath)) { IHttpHandler handler = WebPageHttpHandler.CreateFromVirtualPath(virtualPath); if (handler != null) { SessionStateUtil.SetUpSessionState(context, handler); // Remap to our handler context.RemapHandler(handler); } } } else { // Bug:904704 If its not a match, but to a supported extension, we want to return a 404 instead of a 403 string extension = PathUtil.GetExtension(requestPath); foreach (string supportedExt in registeredExtensions) { if (String.Equals("." + supportedExt, extension, StringComparison.OrdinalIgnoreCase)) { throw new HttpException(404, null); } } } }
internal static WebPageMatch GetWebPageMatch(HttpContextBase context) { WebPageMatch webPageMatch = (WebPageMatch)context.Items[typeof(WebPageMatch)]; return(webPageMatch); }