/// <summary> /// This is called when the request cannot be handed off to IIS /// </summary> public virtual void StaticFileHandler(HttpContext context) { string physicalPath = this.OverrideExecuteUrlPath(); if (FileFtpHandler.AllowScheme(physicalPath)) { FileFtpHandler.ProcessRequestInternal(context, physicalPath); } else { // In case the path is a file:// syntax, we need to convert to physical file path if (UrlHelper.IsFileProtocol(physicalPath)) { Uri pathUri; if (Uri.TryCreate(physicalPath, UriKind.Absolute, out pathUri)) { physicalPath = pathUri.LocalPath; } } if (_supportRanges) { StaticFileHandler3.ProcessRequestInternal(context, physicalPath); } else { StaticFileHandler2.ProcessRequestInternal(context, physicalPath); } } }
internal static void ProcessRequestInternal(HttpContext context, string pathOverride) { HttpResponse httpResponse = context.Response; string physicalPath = context.Request.PhysicalPath; if (pathOverride != null) { physicalPath = pathOverride; } // write out file from ftp to web stream WriteFtp(physicalPath, httpResponse.OutputStream); httpResponse.ContentType = MimeMapping.GetMapping(physicalPath); // set cache headers StaticFileHandler2.SetCachingPolicy(context.Response.Cache); }