4

I just upgraded our Sitecore 8.1 Update 2 install to Sitecore 8.2 Update 1.

Our solution has utilized MVC bundling since we implemented it a year ago.

But now -- after the upgrade -- bundling no longer works correctly.

  • The following Nuget packages are installed:

    • Antlr 3.5.0.2
    • Newtonsoft.Json 9.0.2-beta1
    • Microsoft.Web.Infrastructure 1.0.0
    • Microsoft.AspNet.Web.Optimization 1.1.3
    • WebGrease 1.6.0
  • The namespaces in my Global.asax and Global.asax.cs match.

  • In the head of my layout I have: @Styles.Render("~/bundles/css")

  • In my App_Start/BundleConfig.cs I have:


bundles.Add(new StyleBundle("~/bundles/css").Include(
    "~/assets/css/bootstrap.css",
    "~/assets/css/bootstrap-select.css",
    "~/assets/css/font-awesome.css",
    "~/assets/css/slick.css",
    "~/assets/css/app.css",
    "~/assets/css/back-to-top.css"
));

bundles.Add(new ScriptBundle("~/bundles/js").Include(
    "~/assets/js/navigation.js",
    "~/assets/js/bootstrap.js",
    "~/assets/js/bootstrap-select.js",
    "~/assets/js/handlebars.js",
    "~/assets/js/moment-with-locales.js",
    "~/assets/js/lodash.js",
    "~/assets/js/slick.js",
    "~/assets/js/jquery.browser.js",
    "~/assets/js/jquery.onmutate.js",
    "~/assets/js/js.cookie.js",
    "~/assets/js/main.js",
    "~/assets/js/jquery.validate*",
    "~/assets/js/marketo.js",
    "~/assets/js/back-to-top.js"
));

If I view source I see.

There is no ?v=somerandomstring like one would normally see.

The same thing occurs on my JS bundle.

If I add BundleTable.EnableOptimizations = false; to the end BundleConfig.cs file it has zero effect. The same link gets written into the HTML.

This is driving me nuts. Did something in 8.2 break bundling?


UPDATE:

Removing the following from the Global.asax.cs file breaks the site:

protected void Application_BeginRequest()
{
    Context.Items["Disable"] = new VersionCountDisabler();
}

My guess is that it is expected code and that my patch is not working / in the right place:

<httpRequestBegin>
    <processor type="MySite.Presentation.Pipelines.HttpRequestBegin, MySite.Presentation" patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel']" />
</httpRequestBegin>
  • 1
    Global.asax is private in 8.2. You will need to move your global.asax code to an initialization pipeline. – Chris Auer Dec 16 '16 at 16:53
  • So, I can no longer have my own Global.asax.cs that inherits from Application? How do I go about moving the the code to the intialization pipeline. See my update above so you can see my current Global.asax.cs – eat-sleep-code Dec 16 '16 at 16:57
  • 1
    Yup. Gone. I guess Sitecore wanted to force people into pipelines and out of the Global.asax. Just move you code the example I made below and change the config to your namespace. Its the exact same thing. – Chris Auer Dec 16 '16 at 16:59
  • Only thing, is I don't see one for Application_PreSendRequestHeader on the laubplusco.net site. :-( – eat-sleep-code Dec 16 '16 at 17:02
  • 1
    Add it in web.config: <httpProtocol><customHeaders><add name="X-UA-Compatible" value="IE=Edge" /></customHeaders></httpProtocol> – jammykam Dec 16 '16 at 17:37
4

Global.asax is private in 8.2. You will need to move your global.asax code to an initialization pipeline. Thats why your app_start code isn't running.

namespace YourApp
{
    public class Initialize
    {
        public void Process(PipelineArgs args)
        {
            // app start here
            AreaRegistration.RegisterAllAreas();
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            if (!Tracker.IsActive)
            {
                Tracker.StartTracking();
            }
        }
    }

    public class VersionCount : HttpRequestProcessor
    {
        public override void Process(HttpRequestArgs args)
        {
            args.Context.Items["Disable"] = new VersionCountDisabler();
        }
    }
}

Then your config

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="YourApp.Pipelines.Initialize.YourAppStart, YourApp"
                  patch:before="processor[@type='Sitecore.Pipelines.Loader.ShowVersion, Sitecore.Kernel']" />
      </initialize>
    </pipelines>
  </sitecore>
</configuration>



<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <httpRequestBegin>
        <processor type="YourApp.Pipelines.Initialize.VersionCount, YourApp"
                    patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel']" />
      </httpRequestBegin>
    </pipelines>
  </sitecore>
</configuration>

Other Global.asax functions https://laubplusco.net/global-asax-sitecore-pipelines/

  • Ok, so implemented and now I get a bunch of lovely "Object reference not set" errors on some of my modules that I did not get before. It is like the population of models is getting interrupted? – eat-sleep-code Dec 16 '16 at 18:09
  • Can you give some details on the modules? Using Sitecore models or normal POCO models? – Chris Auer Dec 16 '16 at 18:13
  • Sitecore model. Model.IsValid() is true, but Model.ShowDynamicContent() (which is a public bool exposed in the model) throws the Object reference not set). :-( – eat-sleep-code Dec 16 '16 at 18:17
  • remove the httpRequestBegin pipeline config and test again. We may have it in the wrong order. – Chris Auer Dec 16 '16 at 18:19
  • 1
    I patched the httpRequestBegin one in before Sitecore.Pipelines.PreprocessRequest.CheckIgnoreFlag and that fixed the issue. – eat-sleep-code Dec 19 '16 at 17:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.