+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / C# Bundling (CSS & JS) is not working in sitefinity site.

C# Bundling (CSS & JS) is not working in sitefinity site.

3 posts, 0 answered
  1. Balaji
    Balaji avatar
    8 posts
    Registered:
    13 Nov 2015
    23 Nov 2015
    Link to this post

    Hi Sir/Madam,

     

    We are using C# bundling (css & js) in our current production website which is having normal web forms.  We are converting our site to sitefinity8.2 (mvc model). 

    All works good except the bundling. The bundling is not able to render in the site. Someone advised to add the additional line "BundleTable.VirtualPathProvider =  System.Web.Hosting.HostingEnvironment.VirtualPathProvider;"    to solve the issue . Still it is not working .

     

    See the error log below Please advice us to proceed further.

     

    Timestamp: 11/23/2015 3:24:44 PM

    Message: HandlingInstanceID: bb0fc94a-ace7-45f4-bd12-b6357ff65e87
    An exception of type 'System.ArgumentException' occurred and was caught.
    ------------------------------------------------------------------------
    11/23/2015 09:24:44
    Type : System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : File "/assets/styles" does not exist.
    Parameter name: virtualPath
    Source : Telerik.Sitefinity
    Help link : 
    ParamName : virtualPath
    Data : System.Collections.ListDictionaryInternal
    TargetSite : System.Web.Caching.CacheDependency GetCacheDependency(System.String, System.Collections.IEnumerable, System.DateTime)
    HResult : -2147024809
    Stack Trace :    at Telerik.Sitefinity.Abstractions.VirtualPath.VirtualPathManager.GetCacheDependency(String virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
       at System.Web.Optimization.HttpContextCache.Put(BundleContext context, Bundle bundle, BundleResponse response)
       at System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context)
       at System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath)
       at System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable`1 refs)
       at System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets)
       at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths)
       at ASP.controls_common_abc_css_ascx.__RenderphCSSCombined(HtmlTextWriter __w, Control parameterContainer) in c:\Development\web\comroot-sf\controls\common\ABC_CSS.ascx:line 94
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at ASP.controls_common_abc_css_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\98061bca\a1d62a7b\App_Web_stpyn4ws.2.cs:line 0
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Page.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Thanks,

    Balaji

  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    23 Nov 2015
    Link to this post

    Hi Balaji,

    Did you configured the BundleTables like this?

    protected void Application_Start(object sender, EventArgs e)
    {
       Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += Bootstrapper_Initialized;
     
       // Needed to get the Optimization Framework to work together with Sitefinity
       BundleTable.VirtualPathProvider = HostingEnvironment.VirtualPathProvider;
     
       // Code that runs on application startup
       BundleConfig.RegisterBundles(BundleTable.Bundles);
    }

     

    How did you configured your BundleTables? Do you have an example?
    E.g. see this example:

    bundles.Add(new ScriptBundle("~/bundles/customformsjs").Include(
       "~/Scripts/jquery.customforms.js"
    ));

    Maybe this blogpost is of any help:

    http://www.konstrui.nl/over-ons/blog/daniel-plomp/2014/04/02/implement-the-microsoft-optimization-framework-into-dynamicweb

    Best regards,
    Daniel

  3. Balaji
    Balaji avatar
    8 posts
    Registered:
    13 Nov 2015
    23 Nov 2015 in reply to Daniel Plomp
    Link to this post

    Hi Daniel,

    Thank you for the quick response. We use our master page (custom) which is having few ascx files in it. The styles and scripts are rendering from these ascx files. Basically these ascx code behind are having the logic of generating bundles and rendering the bundles. When the control renders then the bundling will be initiated very first time. We don't call these functions in the app_start event. It's working fine in the current production site.

    So please let me know how to run the same without modifying the existing functionalIty. The master page and controls are global one and they are shared across the sites. My understanding is , currently the new site (what we converting to sitefinity) are routing through sitefinity or the mvc its not rendering.

    Please advice us.

    Thanks,

    Balaji

3 posts, 0 answered