Combres and Sitefinity?

Posted by Community Admin on 04-Aug-2018 21:20

Combres and Sitefinity?

All Replies

Posted by Community Admin on 07-Dec-2011 00:00

I'm having difficulty using Combres css and javascript combination/minification library with Sitecore. What it seems to boil down to is that Combres relies on the System.Web.Routing.UrlRoutingModule which is explicitly removed from the web.config. I need to be able to get this library working in IIS7. Can you please help? Here is what I've found so far to reproduce the issue:

1. Create a new sitefinity plain install
1a. Configure Sitefinity to use IIS Express in Visual Studio 2010 (Or set it up to use IIS7 yourself)
2. Run the setup on everything
3. Create a custom master page file
4. Create a page in sitefinity that uses this master page file
5. Install Combres using the Nuget Package Manager (version 2.2)
6. Insert the combres include server tags to get the CSS references in the head block of the HTML
7. Edit combres.xml file in the app_data directory for 1 valid CSS file. Write a few sample lines of CSS to verify data is being served. Remove the javascript reference.
8. Load up the page. View Source to see the combres reference that it wrote in the head tag.
9. Follow the link to view the CSS file.

Expected: CSS File is displayed
Actual: 404 Error for /combres.axd/siteCss/1234567

I was able to narrow down the issue to where the call is being blocked. If you go into web.config, go to the <system.webServer><modules> section - Comment out this line:

<add name="Sitefinity" type="Telerik.Sitefinity.Web.SitefinityHttpModule, Telerik.Sitefinity" />


So that the SitefinityHttpModule does not load. If you go back to the URL in IIS7 or IIS Express (/combres.axd/siteCss/1234567) You will notice that the CSS now loads. So it's this module that is preventing Combres from working.

Since Combres relies on the System.Web.Routing.UrlRoutingModule, is there any way to get this library to work within Sitefinity? Are there any other libraries similar to Combres that are known to work well with Sitefinity that will do CSS/JS Combination and Minification?

====Edit====
Link to Combres: nuget.org/.../combres
http://combres.codeplex.com/

Posted by Community Admin on 12-Dec-2011 00:00

Hi Ken Sykora,

 If you want to load all of your css files in an optimized way, you do not need to use the Combres library. Sitefinity combines all stylesheets and scripts in one file out-of-the-box. You can load the sheets/scripts in your master page in various different ways (use the link tag or the Resource links control like this):

<sitefinity:ResourceLinks ID="ResourceLinks1" runat="server" UseEmbeddedThemes="false" >
                <sitefinity:ResourceFile  Name="~/Sitefinity/WebsiteTemplates/test/App_Themes/test/css/main.css" />
</sitefinity:ResourceLinks>
About the Combres library, I don't think it would work, because Sitefinity uses its own handlers to load .css and javascript files and Combres isn't really needed.
Where you can check if the combining is turned on and turned it off if you want is in Settings >> Advanced >> Pages and look for the "Combine style sheet resources" and "Combine script resources" properties.


Greetings,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Dec-2011 00:00

Hi Svetoslav:

I used the sample code you provided below, but I'm running into issues. Here's what I did:

<sitefinity:ResourceLinks runat="server" UseEmbeddedThemes="false">
        <sitefinity:ResourceFile Static="true" IsFromTheme="false" Name="~/assets/scripts/jquery.min.js"/>
        <sitefinity:ResourceFile Static="true" IsFromTheme="false" Name="~/assets/scripts/fancybox/jquery.mousewheel-3.0.4.pack.js"/>
        <sitefinity:ResourceFile Static="true" IsFromTheme="false" Name="~/assets/scripts/fancybox/jquery.easing-1.3.pack.js"/>
        <sitefinity:ResourceFile Static="true" IsFromTheme="false" Name="~/assets/scripts/custom-form-elements.js"/>
        <sitefinity:ResourceFile Static="true" IsFromTheme="false" Name="~/assets/scripts/global.js"/>
    </sitefinity:ResourceLinks>

I logged into the Sitefinity backend, went to Advanced, and both Combine properties are already set to "True", but the scripts do not get rendered as combined, they are still output as regular script blocks. Do you know what I'm missing here?

Posted by Community Admin on 27-Dec-2011 00:00

Hello,

 Here's how to combine all the scripts with RadScriptManager (this will surely work) - in the example my files are called JScript1 and JScript2 and are located in folder Scripts inside the root of SitefinityWebApp:
1)In your master page, add this code just before the closing <form> tag:

<telerik:RadScriptManager runat="server" ID="Manager1" EnableScriptCombine="true">
    <Scripts>
    <asp:ScriptReference Name="SitefinityWebApp.Scripts.JScript1.js" Assembly="SitefinityWebApp" />
    <asp:ScriptReference Name="SitefinityWebApp.Scripts.JScript2.js" Assembly="SitefinityWebApp" />
    </Scripts>
    </telerik:RadScriptManager>
2) Select the script files and from properties change the Build Action to "Embedded Resource"
3)In AssemblyInfo.cs add the following lines (the names of the resource everywhere should be Namespace.NameOfScriptFile):
[assembly: WebResource("SitefinityWebApp.Scripts.JScript1.js", "application/x-javascript")]
[assembly: WebResource("SitefinityWebApp.Scripts.JScript2.js", "application/x-javascript")]
4) Finally in web.config add this:
<add name="Telerik.Web.UI.WebResource" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2011.3.1115.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
The version should be the one of Telerik.Web.UI, which in your case will be different, because I tested this on a 4.4 project. You can check the version of this assembly from the References.
Now build and run the project.
Basically what we did is use the RadScriptManager, but in order to do that we needed to make the scripts web resource.
Let me know if this didn't work for you.

Kind regards,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed