Sitecore

Sitecore and Bundling


A short note on Sitecore and Bundling.

If you use Bundling within your WebApplication you will maybe wondering why your Script and css files not rendered properly:

 Failed to load resource: the server responded with a status of 404 (Not Found)
 http://YourDomain/sitecore/service/notfound?item=%2fbundles%2fmodernizr&user=sitecore%5cadmin&site=YourSiteName

or

 Failed to load resource: the server responded with a status of 404 (Not Found)
 http://YourDomain/sitecore/service/notfound?item=%2fcontent%2fcss&user=sitecore%5cadmin&site=YourSiteName

Sitecore tries to resolve your Bundles as an item. But you can get rid of this with a simple setting adjustment in web.config.

<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing" />

Here we go! Just add your bundle-urls pipe-separated to the IgnoreUrlPrefixes-value

<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/bundles|/Content/css" />

Best practise:

It’s highly recommended to patch such Settings in your own Settings.config-file in App_Config/Include-Folder like this:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
   <settings>
       <!-- IGNORE URLS
       Set IgnoreUrlPrefixes to a '|' separated list of url prefixes that should not be
       regarded and processed as friendly urls (ie. forms etc.)
       -->
       <setting name="IgnoreUrlPrefixes">
         <patch:attribute name="value">/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/bundles|/Content/css</patch:attribute>
       </setting>
     </settings>
   </sitecore>
</configuration>