This is a migrated thread and some comments may be shown as answers.

Why won't the scripts or css compress?

13 Answers 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
William Hurst
Top achievements
Rank 1
William Hurst asked on 28 Aug 2010, 01:53 PM
My javascript and css is combining correctly but they never seem to compress. I have set debug="false" but is there something else I need to do to enable compression?

<% Html.Telerik().ScriptRegistrar().DefaultGroup(g => g.Enabled(true)
        .Add("~/Scripts/jquery.validate.js")
        .Add("~/Scripts/MicrosoftMvcJQueryValidation.js")
        .Add("~/Scripts/Website/Common.Website.js")
        .Add("~/Scripts/jquery.blockUI.js")
        .Add("~/Plugins/jquery.fancybox/fancybox/jquery.fancybox-1.3.1.js")
        .Add("~/Plugins/jquery.fancybox/fancybox/jquery.easing-1.3.pack.js")
        .Add("~/Scripts/jquery.form.js")
        .Add("~/Scripts/Website/jquery.swfobject.js")
        .Add("~/Scripts/Website/jquery.sifr.js")
        .Add("~/Scripts/Website/jquery.watermark.js")
        .Compress(true).Combined(true)); %>

13 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 29 Aug 2010, 08:54 AM
Hi,

Did you check this help topic ?

Regards,
Peter
0
William Hurst
Top achievements
Rank 1
answered on 29 Aug 2010, 07:50 PM
Hi Peter, I have seen that help topic and I didn't see anything different to what I am doing above.
0
Atanas Korchev
Telerik team
answered on 30 Aug 2010, 08:29 AM
Hello William Hurst,

This may occur if you are using IE6 or your browser does not indicate that it supports compression. If this is not the case I would suggest you send us a sample project.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fred Chateau
Top achievements
Rank 1
answered on 18 Sep 2010, 04:46 PM
In my case, the problem is not with the compression. It's releated to the combine setting.

When I set combine to true it returns the error: Cannot use a leading .. to exit above the top directory.

I have tried every combination of path I can think of, and also included switching to the AddGroup method, but nothing works. In fact, you can tell when you've picked a right combination of path because it returns this error. Otherwise it returns examples of what's wrong, I've gotten examples, such as: Cannot find ~/Content/Content/site.css, and ~/Content/../site.css, but when the path it correct, it returns the above error.
0
Fred Chateau
Top achievements
Rank 1
answered on 18 Sep 2010, 04:48 PM

> If this is not the case I would suggest you send us a sample project.

You don't need a sample project. The error is OBVIOUS! Just try entering the code above.
0
William Hurst
Top achievements
Rank 1
answered on 18 Sep 2010, 06:13 PM
Fred, I'm not sure how our issues are related, sorry.

Telerik: I am not using IE 6 and unfortunately I can't send an example project. The original post includes the code used on http://www.eatout.co.za (which is live and so has debug=false). If you view the source you will notice it has combined but not compressed.
0
Atanas Korchev
Telerik team
answered on 18 Sep 2010, 07:34 PM
Hi,

Our online demos register CSS like this:

<%= Html.Telerik().StyleSheetRegistrar()
                      .DefaultGroup(group => group
                          .Add("telerik.examples.css")
                          .Add("telerik.common.css")
                          .Add("telerik." + Html.GetCurrentTheme() + ".css")
                          .Combined(true)
                          .Compress(true))
                     %>
Both telerik.examples.css and telerik.common.css are located in the ~/Content folder of the application. By design all assets registered with the StyleSheetRegistrar are expected to be in the Content folder. To change that you must use the DefaultPath of the group:

group => group.DefaultPath("~/SomePath")

I hope this helps,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fred Chateau
Top achievements
Rank 1
answered on 18 Sep 2010, 10:13 PM

Thanks for trying to help, Atanas.

Don't know if this will do any good, but i can't think of anything I'm doing that's different from your examples.

[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]
   System.Web.Util.UrlPath.ReduceVirtualPath(String path) +11251721
   System.Web.Util.UrlPath.ReduceVirtualPath(String path) +11252000
   System.Web.Util.UrlPath.Reduce(String path) +64
   System.Web.VirtualPath.Combine(VirtualPath relativePath) +152
   System.Web.VirtualPathUtility.Combine(String basePath, String relativePath) +46
   Telerik.Web.Mvc.Infrastructure.Implementation.VirtualPathProviderWrapper.CombinePaths(String basePath, String relativePath) +27
   Telerik.Web.Mvc.<>c__DisplayClass17.<ReplaceImagePath>b__16(Match match) +237
   System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat) +244
   System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator) +84
   Telerik.Web.Mvc.WebAssetRegistry.ReplaceImagePath(String baseDiretory, String content) +141
   Telerik.Web.Mvc.WebAssetRegistry.EnsureAsset(MergedAsset asset, String id) +849
   Telerik.Web.Mvc.WebAssetRegistry.Store(String contentType, WebAssetItemGroup assetGroup) +142
   Telerik.Web.Mvc.UI.WebAssetItemMerger.ProcessGroup(WebAssetItemGroup group, String contentType, String assetHandlerPath, IList`1 urls) +391
   Telerik.Web.Mvc.UI.WebAssetItemMerger.MergeGroup(String contentType, String assetHandlerPath, Boolean isSecured, Boolean canCompress, WebAssetItemGroup group) +618
   Telerik.Web.Mvc.UI.WebAssetItemMerger.Merge(String contentType, String assetHandlerPath, Boolean isSecured, Boolean canCompress, WebAssetItemCollection assets) +370
   Telerik.Web.Mvc.UI.<>c__DisplayClass2.<Write>b__1(WebAssetItemCollection assets) +71
   Telerik.Web.Mvc.UI.StyleSheetRegistrar.Write(TextWriter writer) +252
   Telerik.Web.Mvc.UI.StyleSheetRegistrar.Render() +63
   ASP.views_blank_master.__RenderHead1(HtmlTextWriter __w, Control parameterContainer) in d:\SlateXP\Source\Trunk\SlateXP.net\SlateXP.Web\Views\Blank.Master:23
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +115
   System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) +23
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
   System.Web.UI.Page.Render(HtmlTextWriter writer) +38
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +89
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4240
0
Georgi Krustev
Telerik team
answered on 20 Sep 2010, 07:27 AM
Hello Fred,

This exception will be thrown if you are trying to set DefaultPath to URL which starts or contains ",,/". This is not supported. You need to use only virtual path to set Default one in Script/StyleSheet registrar.

Best wishes,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fred Chateau
Top achievements
Rank 1
answered on 20 Sep 2010, 04:39 PM
Well, that's the problem...

I'm not setting DefaultPath at all (not even sure how to), so it should be using a built-in MVC default path ("~/Content"), right? I have tried adding a Group, and setting the group path, but that didn't help either.

Here's the current code:

<%
Html.Telerik().StyleSheetRegistrar()
.DefaultGroup(group => group.Add("telerik.common.min.css") 
.Add("Site.css").Add("grid.css") 
.Combined(true).CacheDurationInDays(1).Compress(true)) 
.Render();
%>

 
Where "telerik.common.min.css" is in "~/Content/2010.2.825".
"Site.css" and "grid.css" are in "~/Content".

0
Atanas Korchev
Telerik team
answered on 20 Sep 2010, 04:55 PM
Hello Fred Chateau,

The code you are using looks correct. I am sending you a working application which should behave as expected.

This problem may be due to an image url in your CSS file which is causing this problem. You can see if your css file contains ../ in some of the images urls. When web asset combination is enabled the url of the CSS file changes and we run some code to fix the image paths to be relative according that new path. It is possible that this code does not work properly in your case.

You can try excluding CSS files one by one to find the problematic one. If this is the case please paste the file contents here so we can test whether it is causing a bug in our image URL replacement code.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fred Chateau
Top achievements
Rank 1
answered on 20 Sep 2010, 05:41 PM
That resolved the problem.

I found two URL's that were not relative to the root:
    url(images/logo1.gif) changed to url(/Images/logo1.gif)
and
    url(../../Images/logo2.gif) changed to url(/Images/logo2.gif)

If you need the entire css file, let me know.
0
Atanas Korchev
Telerik team
answered on 21 Sep 2010, 07:44 AM
Hello Fred Chateau,

 I think it is the second one which breaks our code:
../../Images/logo2.gif

I will investigate that further to see if we can support it too.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
William Hurst
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
William Hurst
Top achievements
Rank 1
Atanas Korchev
Telerik team
Fred Chateau
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or