Inheritance: IHttpHandler
Example #1
0
            public override Task DoActionAsync(bool onRemote, bool isFromMe, CancellationToken cancellationToken)
            {
                // Cleaning the cache for the given path
                BundleHandler.InvalidateCacheForPath(Path);

                return(Task.CompletedTask);
            }
Example #2
0
        private static void OnPreRenderComplete(object sender, EventArgs args)
        {
            // Add a link tag for every CSS bundle in the current PortalContext

            var header = ((System.Web.UI.Page)sender).Header;

            foreach (var bundle in Current.CssBundles)
            {
                // Also adding it to the bundle handler
                bundle.Close();
                BundleHandler.AddBundleIfNotThere(bundle);
                ThreadPool.QueueUserWorkItem(x => BundleHandler.AddBundleToCache(bundle));

                if (BundleHandler.IsBundleInCache(bundle))
                {
                    var cssLink = new HtmlLink();

                    cssLink.Href = "/" + BundleHandler.UrlPart + "/" + bundle.FakeFilename;
                    cssLink.Attributes["rel"]   = "stylesheet";
                    cssLink.Attributes["type"]  = bundle.MimeType;
                    cssLink.Attributes["media"] = bundle.Media;

                    header.Controls.Add(cssLink);
                }
                else
                {
                    // The bundle will be complete in a few seconds; disallow caching the page until then
                    HttpHeaderTools.SetCacheControlHeaders(httpCacheability: HttpCacheability.NoCache);

                    foreach (var path in bundle.Paths)
                    {
                        UITools.AddStyleSheetToHeader(header, path, 0, "stylesheet", bundle.MimeType, bundle.Media, string.Empty, false);
                    }
                }

                foreach (var postponedPath in bundle.PostponedPaths)
                {
                    UITools.AddStyleSheetToHeader(header, postponedPath, 0, "stylesheet", bundle.MimeType, bundle.Media, string.Empty, false);
                }
            }
        }
Example #3
0
 public override void DoAction(bool onRemote, bool isFromMe)
 {
     // Cleaning the cache for the given path
     BundleHandler.InvalidateCacheForPath(Path);
 }