public void ProcessRequest(HttpRequest request, Site site) { if (request.URL.AbsolutePath == _fileIconPath) { request.UseResponseStream(_browserImages[_fileIconPath]); request.ResponseHeaders.ContentType = HttpUtility.GetContentTypeForExtension("png"); return; } else if (request.URL.AbsolutePath == _folderIconPath) { request.UseResponseStream(_browserImages[_folderIconPath]); request.ResponseHeaders.ContentType = HttpUtility.GetContentTypeForExtension("png"); return; } else if (request.URL.AbsolutePath == _downloadIconPath) { request.UseResponseStream(_browserImages[_downloadIconPath]); request.ResponseHeaders.ContentLength = HttpUtility.GetContentTypeForExtension("png"); return; } IDirectoryFolder idf = (IDirectoryFolder)request["IFolder"]; string path = request.URL.AbsolutePath; path = path.Substring(((string)request["IFolderPath"]).Length); if (path.StartsWith("/")) path = path.Substring(1); IDirectoryFile ifile = null; IDirectoryFolder ifold = null; if (path == "" || path == "/") ifold = idf; else LocateObjectForPath((path.EndsWith("/") ? path : path + "/"), idf, out ifold, out ifile); if (request.Parameters["DownloadPath"] != null) { path = (path.EndsWith("/") ? path.Substring(0,path.Length-1) : path); if (ifile != null) { request.UseResponseStream(ifile.ContentStream); request.ResponseHeaders.ContentType = HttpUtility.GetContentTypeForExtension(path.Substring(path.LastIndexOf("."))); } else { ZipFile zf = new ZipFile(path.Substring(path.LastIndexOf("/") + 1)); string basePath = Utility.TraceFullDirectoryPath(ifold); zf.AddDirectory(ifold,basePath.Substring(0,basePath.Length-ifold.Name.Length)); request.UseResponseStream(zf.ToStream()); request.ResponseHeaders.ContentType = zf.ContentType; request.ResponseHeaders["Content-Disposition"] = "attachment; filename=" + zf.Name+"."+zf.Extension; } } else { if (ifile != null) { request.UseResponseStream(ifile.ContentStream); request.ResponseHeaders.ContentType = HttpUtility.GetContentTypeForExtension(path.Substring(path.LastIndexOf("."))); } else if (ifold != null) { request.ResponseHeaders.ContentType = "text/html"; request.ResponseWriter.Write(RenderFolderBrowser(ifold,site,request)); } else { request.ResponseStatus = HttpStatusCodes.Not_Found; request.ResponseWriter.WriteLine("<h1>Unable to locate the folder at the path " + request.URL.AbsolutePath + "</h1>"); } } }