public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            bool isIe = HttpContext.Current.Request.Browser.Browser.Trim()
                        .Equals("IE", StringComparison.InvariantCultureIgnoreCase);
            int ieVersion = isIe ? HttpContext.Current.Request.Browser.MajorVersion : 0;

            ICombinerService myCombiner = CombinerServiceFactory.CreateCombinerService();

            var logger = new LoggingService.LoggingService();

            // Set the Response.Filter to our custom Stream class that will do the parsing of the html
            // and the replacement of the script and css tags with the combined resources tags.
            filterContext.HttpContext.Response.Filter =
                new CombinerResponseStream(
                    filterContext.HttpContext.Response.Filter,
                    CombinerLiveSettings.CombineJs && _combineJs,
                    CombinerLiveSettings.CombineCss && _combineCss,
                    CombinerLiveSettings.MinifyJs && _minifyJs,
                    CombinerLiveSettings.MinifyCss && _minifyCss,
                    CombinerLiveSettings.VersionOnly && _versionOnly,
                    CombinerLiveSettings.PrependCdnHostToImages && _prependCdnHostToImages,
                    CombinerLiveSettings.JsVersion,
                    CombinerLiveSettings.CssVersion,
                    CombinerConstantsAndSettings.JsAndCssSharedVersion,
                    ieVersion,
                    HttpContext.Current.Request.Url.AbsolutePath.TrimEnd('/'),
                    myCombiner,
                    logger,
                    CombinerConstantsAndSettings.WebSettings.ComboScriptUrl,
                    CombinerConstantsAndSettings.WebSettings.ImagesCdnHostToPrepend
                    );

            if (_applyOutputCaching)
            {
                // Set cacheability
                filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
                filterContext.HttpContext.Response.Cache.SetValidUntilExpires(true);
                filterContext.HttpContext.Response.Cache.VaryByParams["*"] = true;

                // Set file dependency for output cache
                // when the live.js is updated we need to invalidate the OutputCache for this page
                string path = CombinerConstantsAndSettings.WebSettings.CombinerLiveSettingsFile;
                string liveSettingsFilePath = filterContext.HttpContext.Server.MapPath(path);

                filterContext.HttpContext.Response.AddFileDependency(liveSettingsFilePath);
            }

            base.OnResultExecuting(filterContext);
        }
Exemplo n.º 2
0
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            bool isIe = HttpContext.Current.Request.Browser.Browser.Trim()
                .Equals("IE", StringComparison.InvariantCultureIgnoreCase);
            int ieVersion = isIe ? HttpContext.Current.Request.Browser.MajorVersion : 0;

            ICombinerService myCombiner = CombinerServiceFactory.CreateCombinerService();

            var logger = new LoggingService.LoggingService();

            // Set the Response.Filter to our custom Stream class that will do the parsing of the html
            // and the replacement of the script and css tags with the combined resources tags.
            filterContext.HttpContext.Response.Filter =
                new CombinerResponseStream(
                    filterContext.HttpContext.Response.Filter,
                    CombinerLiveSettings.CombineJs && _combineJs,
                    CombinerLiveSettings.CombineCss && _combineCss,
                    CombinerLiveSettings.MinifyJs && _minifyJs,
                    CombinerLiveSettings.MinifyCss && _minifyCss,
                    CombinerLiveSettings.VersionOnly && _versionOnly,
                    CombinerLiveSettings.PrependCdnHostToImages && _prependCdnHostToImages,
                    CombinerLiveSettings.JsVersion,
                    CombinerLiveSettings.CssVersion,
                    CombinerConstantsAndSettings.JsAndCssSharedVersion,
                    ieVersion,
                    HttpContext.Current.Request.Url.AbsolutePath.TrimEnd('/'),
                    myCombiner,
                    logger,
                    CombinerConstantsAndSettings.WebSettings.ComboScriptUrl,
                    CombinerConstantsAndSettings.WebSettings.ImagesCdnHostToPrepend
                    );

            if (_applyOutputCaching)
            {
                // Set cacheability
                filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
                filterContext.HttpContext.Response.Cache.SetValidUntilExpires(true);
                filterContext.HttpContext.Response.Cache.VaryByParams["*"] = true;

                // Set file dependency for output cache
                // when the live.js is updated we need to invalidate the OutputCache for this page
                string path = CombinerConstantsAndSettings.WebSettings.CombinerLiveSettingsFile;
                string liveSettingsFilePath = filterContext.HttpContext.Server.MapPath(path);

                filterContext.HttpContext.Response.AddFileDependency(liveSettingsFilePath);
            }

            base.OnResultExecuting(filterContext);
        }
Exemplo n.º 3
0
        protected override void OnPreRender(EventArgs e)
        {
            bool isIe = HttpContext.Current.Request.Browser.Browser.Trim()
                        .Equals("IE", StringComparison.InvariantCultureIgnoreCase);
            int ieVersion = isIe ? HttpContext.Current.Request.Browser.MajorVersion : 0;

            ICombinerService myCombiner = CombinerServiceFactory.CreateCombinerService();

            var logger = new LoggingService.LoggingService();

            HttpContext.Current.Response.Filter =
                new CombinerResponseStream(
                    HttpContext.Current.Response.Filter,
                    CombinerLiveSettings.CombineJs && CombineJs.GetValueOrDefault(true),
                    CombinerLiveSettings.CombineCss && CombineCss.GetValueOrDefault(true),
                    CombinerLiveSettings.MinifyJs && MinifyJs.GetValueOrDefault(true),
                    CombinerLiveSettings.MinifyCss && MinifyCss.GetValueOrDefault(true),
                    CombinerLiveSettings.VersionOnly && VersionOnly.GetValueOrDefault(true),
                    CombinerLiveSettings.PrependCdnHostToImages && PrependCdnHostToImages.GetValueOrDefault(true),
                    CombinerLiveSettings.JsVersion,
                    CombinerLiveSettings.CssVersion,
                    CombinerConstantsAndSettings.JsAndCssSharedVersion,
                    ieVersion,
                    HttpContext.Current.Request.Url.AbsolutePath,
                    myCombiner,
                    logger,
                    CombinerConstantsAndSettings.WebSettings.ComboScriptUrl,
                    CombinerConstantsAndSettings.WebSettings.ImagesCdnHostToPrepend
                    );

            if (ApplyOutputCaching.GetValueOrDefault(true))
            {
                // Set cacheability
                HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
                HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
                HttpContext.Current.Response.Cache.SetValidUntilExpires(true);
                HttpContext.Current.Response.Cache.VaryByParams["*"] = true;

                // Set file dependency for output cache
                // when the live.js is updated we need to invalidate the OutputCache for this page
                string path = CombinerConstantsAndSettings.WebSettings.CombinerLiveSettingsFile;
                string liveSettingsFilePath = HttpContext.Current.Server.MapPath(path);

                HttpContext.Current.Response.AddFileDependency(liveSettingsFilePath);
            }
        }
Exemplo n.º 4
0
        protected override void OnPreRender(EventArgs e)
        {
            bool isIe = HttpContext.Current.Request.Browser.Browser.Trim()
                .Equals("IE", StringComparison.InvariantCultureIgnoreCase);
            int ieVersion = isIe ? HttpContext.Current.Request.Browser.MajorVersion : 0;

            ICombinerService myCombiner = CombinerServiceFactory.CreateCombinerService();

            var logger = new LoggingService.LoggingService();

            HttpContext.Current.Response.Filter =
                new CombinerResponseStream(
                    HttpContext.Current.Response.Filter,
                    CombinerLiveSettings.CombineJs && CombineJs.GetValueOrDefault(true),
                    CombinerLiveSettings.CombineCss && CombineCss.GetValueOrDefault(true),
                    CombinerLiveSettings.MinifyJs && MinifyJs.GetValueOrDefault(true),
                    CombinerLiveSettings.MinifyCss && MinifyCss.GetValueOrDefault(true),
                    CombinerLiveSettings.VersionOnly && VersionOnly.GetValueOrDefault(true),
                    CombinerLiveSettings.PrependCdnHostToImages && PrependCdnHostToImages.GetValueOrDefault(true),
                    CombinerLiveSettings.JsVersion,
                    CombinerLiveSettings.CssVersion,
                    CombinerConstantsAndSettings.JsAndCssSharedVersion,
                    ieVersion,
                    HttpContext.Current.Request.Url.AbsolutePath,
                    myCombiner,
                    logger,
                    CombinerConstantsAndSettings.WebSettings.ComboScriptUrl,
                    CombinerConstantsAndSettings.WebSettings.ImagesCdnHostToPrepend
                    );

            if (ApplyOutputCaching.GetValueOrDefault(true))
            {
                // Set cacheability
                HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
                HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
                HttpContext.Current.Response.Cache.SetValidUntilExpires(true);
                HttpContext.Current.Response.Cache.VaryByParams["*"] = true;

                // Set file dependency for output cache
                // when the live.js is updated we need to invalidate the OutputCache for this page
                string path = CombinerConstantsAndSettings.WebSettings.CombinerLiveSettingsFile;
                string liveSettingsFilePath = HttpContext.Current.Server.MapPath(path);

                HttpContext.Current.Response.AddFileDependency(liveSettingsFilePath);
            }
        }