public void Start() { foreach (var vppElement in configFactory.Sections.Web.Vpp.Zips.AllElements) { string virtualPath = vppElement.VirtualPath; string zipPath = MapPath(virtualPath); if (!File.Exists(zipPath)) { Trace.TraceWarning("Did not find configured (" + vppElement.Name + ") zip vpp on disk: " + zipPath); continue; } var vpp = new Ionic.Zip.Web.VirtualPathProvider.ZipFileVirtualPathProvider(zipPath); Register(vpp); broker.BeginRequest += (s, a) => { var app = s as HttpApplication; var ctx = app.Context; var requestPath = ctx.Request.AppRelativeCurrentExecutionFilePath; if (!requestPath.StartsWith(virtualPath, StringComparison.InvariantCultureIgnoreCase)) { return; } if (!vpp.DirectoryExists(requestPath)) { return; } ctx.RewritePath(requestPath.TrimEnd('/') + "/Default.aspx"); }; } }
public void Start() { foreach (var vppElement in configFactory.Sections.Web.Vpp.Zips.AllElements) { string virtualPath = vppElement.VirtualPath; string zipPath = MapPath(virtualPath); if (!File.Exists(zipPath)) { Trace.TraceWarning("Did not find configured (" + vppElement.Name + ") zip vpp on disk: " + zipPath); continue; } var vpp = new Ionic.Zip.Web.VirtualPathProvider.ZipFileVirtualPathProvider(zipPath); Register(vpp); broker.BeginRequest += (s, a) => { var app = s as HttpApplication; var ctx = app.Context; var requestPath = ctx.Request.AppRelativeCurrentExecutionFilePath; if (!requestPath.StartsWith(virtualPath, StringComparison.InvariantCultureIgnoreCase)) return; if (!vpp.DirectoryExists(requestPath)) return; ctx.RewritePath(requestPath.TrimEnd('/') + "/Default.aspx"); }; } }
public void Start() { var staticFileExtensions = configFactory.Sections.Web.Vpp.Zips.StaticFileExtensions.OfType <string>().ToList(); foreach (var vppElement in configFactory.Sections.Web.Vpp.Zips.AllElements) { string filePath = vppElement.FilePath; string observedPath = vppElement.ObservedPath; string path = MapPath(filePath); if (!File.Exists(path)) { Trace.TraceWarning("Did not find configured (" + vppElement.Name + ") zip vpp on disk: " + path); continue; } DateTime lastModified = File.GetLastWriteTimeUtc(path); var vpp = new Ionic.Zip.Web.VirtualPathProvider.ZipFileVirtualPathProvider(path); Trace.WriteLine("Registering VPP: " + vpp); Register(vpp); broker.PostResolveAnyRequestCache += (s, a) => { var application = s as HttpApplication; var context = application.Context; var requestPath = context.Request.AppRelativeCurrentExecutionFilePath; if (!requestPath.StartsWith(observedPath, StringComparison.InvariantCultureIgnoreCase)) { return; } if (!vpp.DirectoryExists(VirtualPathUtility.GetDirectory(requestPath))) { return; } string extension = VirtualPathUtility.GetExtension(requestPath).ToLower(); if (extension == "") { requestPath = requestPath.TrimEnd('/') + "/Default.aspx"; //context.RewritePath(requestPath.TrimEnd('/') + "/Default.aspx"); } // There's a problem with RouteTable.Routes keeping storing the default vpp before we register our vpp, in which case // RouteExistingFiles will not handle files in the zip vpp. This is a workaround. if (extension == "" || extension == ".aspx" || extension == ".axd" || extension == ".ashx") { if (vpp.FileExists(requestPath)) { var handler = System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(requestPath, typeof(IHttpHandler)); context.RemapHandler(handler as IHttpHandler); } } else if (staticFileExtensions.Contains(extension) && vpp.FileExists(requestPath)) { context.RemapHandler(new VirtualPathFileHandler() { Modified = lastModified }); } }; } }
public void Start() { var staticFileExtensions = configFactory.Sections.Web.Vpp.Zips.StaticFileExtensions.OfType<string>().ToList(); foreach (var vppElement in configFactory.Sections.Web.Vpp.Zips.AllElements) { string filePath = vppElement.FilePath; string observedPath = vppElement.ObservedPath; string path = MapPath(filePath); if (!File.Exists(path)) { Trace.TraceWarning("Did not find configured (" + vppElement.Name + ") zip vpp on disk: " + path); continue; } DateTime lastModified = File.GetLastWriteTimeUtc(path); var vpp = new Ionic.Zip.Web.VirtualPathProvider.ZipFileVirtualPathProvider(path); Trace.WriteLine("Registering VPP: " + vpp); Register(vpp); broker.PostResolveAnyRequestCache += (s, a) => { var application = s as HttpApplication; var context = application.Context; var requestPath = context.Request.AppRelativeCurrentExecutionFilePath; if (!requestPath.StartsWith(observedPath, StringComparison.InvariantCultureIgnoreCase)) return; if (!vpp.DirectoryExists(VirtualPathUtility.GetDirectory(requestPath))) return; string extension = VirtualPathUtility.GetExtension(requestPath).ToLower(); if (extension == "") requestPath = requestPath.TrimEnd('/') + "/Default.aspx"; //context.RewritePath(requestPath.TrimEnd('/') + "/Default.aspx"); // There's a problem with RouteTable.Routes keeping storing the default vpp before we register our vpp, in which case // RouteExistingFiles will not handle files in the zip vpp. This is a workaround. if (extension == "" || extension == ".aspx" || extension == ".axd" || extension == ".ashx") { if (vpp.FileExists(requestPath)) { var handler = System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(requestPath, typeof(IHttpHandler)); context.RemapHandler(handler as IHttpHandler); } } else if (staticFileExtensions.Contains(extension) && vpp.FileExists(requestPath)) context.RemapHandler(new VirtualPathFileHandler() { Modified = lastModified }); }; } }