<% 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
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
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.
> 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.
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.
Our online demos register CSS like this:
<%= Html.Telerik().StyleSheetRegistrar()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:
.DefaultGroup(group => group
.Add("telerik.examples.css")
.Add("telerik.common.css")
.Add("telerik." + Html.GetCurrentTheme() + ".css")
.Combined(true)
.Compress(true))
%>
group => group.DefaultPath("~/SomePath")
I hope this helps,
Atanas Korchev
the Telerik team
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 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
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".
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.
Atanas Korchev
the Telerik team
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.
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.
Atanas Korchev
the Telerik team