Cassette 404 error when debug=false

185 views
Skip to first unread message

Elliot

unread,
Apr 15, 2016, 4:02:32 AM4/15/16
to Cassette
  • I'm using Cassette 2.4.2 with .NET framework 4.5.1. I'm also using Umbraco  7.4.2, although i don't believe the error is related to Umbraco.
  • If I set the web config such that cassette is not in debug mode, my application can't find any of its bundles.
  • I get 404 Not Found error in the chrome console for every bundle that is referenced on every page.
  • Not sure why this is happening when debug=false, as it works perfectly with no 404 errors when debug=true.
  • Here are the relevant parts of my code:
CassetteBundleConfiguration.cs
namespace xxx.Configuration
{
   using Cassette;
   using Cassette.Scripts;
   using Cassette.Stylesheets;

   public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
   {
      private static void Stylesheets(BundleCollection bundles)
      {
         bundles.AddPerSubDirectory<StylesheetBundle>("~/content/styles", true);
         bundles.AddPerSubDirectory<StylesheetBundle>("~/content/styles/vendor", true);
         bundles.AddPerSubDirectory<StylesheetBundle>("~/content/styles/examples", true);
         bundles.Get<StylesheetBundle>("~/content/styles/vendor/slickjs").Media = "screen, projection";
      }

      private static void Scripts(BundleCollection bundles)
      {
         bundles.AddPerSubDirectory<ScriptBundle>("~/content/js", true);
         bundles.AddPerSubDirectory<ScriptBundle>("~/content/js/vendor", true);
         bundles.AddPerSubDirectory<ScriptBundle>("~/content/js/examples", true);
         bundles.AddUrlWithAlias("//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js", "~/jquery");
         bundles.AddUrlWithLocalAssets("//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js",
                                        new LocalAssetSettings
                                        {
                                           FallbackCondition = "!window.jQuery",
                                           Path = "~/content/js/vendor/jquery"
                                        }
         );
         bundles.AddUrlWithAlias<ScriptBundle>("//maps.google.com/maps/api/js?sensor=false", "~/google-maps");
         bundles.AddUrlWithLocalAssets<ScriptBundle>("//maps.google.com/maps/api/js?sensor=false",
                                        new LocalAssetSettings
                                        {
                                           FallbackCondition = "!window.google",
                                           Path = "~/content/js/vendor/google-maps"
                                        }
         );
      }

      public void Configure(BundleCollection bundles)
      {
         Stylesheets(bundles);
         Scripts(bundles);
      }
   }
}

Master.cshtml (Master template file)
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
   Layout = null;
   Bundles.Reference("~/content/styles/master");
   Bundles.Reference("~/content/js/master");
}

<!DOCTYPE html>
<html>
   <head>
      <title>@CurrentPage.title</title>
      @Bundles.RenderStylesheets()
   </head>

   <body>
      @RenderBody()

      @Bundles.RenderScripts()
   </body>
</html>

Web.config (the bits that may matter)
<configuration>
   <configSections>
      <section name="cassette" type="Cassette.CassetteConfigurationSection, Cassette" requirePermission="false" />
   </configSections>
   <pages enableEventValidation="false">
      <namespaces>
         <add namespace="Cassette.Views" />
      </namespaces>
   </pages>

   <httpModules>
      <add name="CassetteHttpModule" type="Cassette.Aspnet.CassetteHttpModule, Cassette.Aspnet" />
   </httpModules>

   <httpHandlers>
      <add path="cassette.axd" verb="*" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
   </httpHandlers>

   <compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.5">
   </compilation>

   <modules runAllManagedModulesForAllRequests="true">
      <add name="CassetteHttpModule" type="Cassette.Aspnet.CassetteHttpModule, Cassette.Aspnet" />
   </modules>

   <handlers accessPolicy="Read, Write, Script, Execute">
      <add name="CassetteHttpHandler" path="cassette.axd" preCondition="integratedMode" verb="*" allowPathInfo="true" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
   </handlers>

   <cassette debug="false"/>
</configuration>

If I head to /cassette.axd, the bundles are still listed.



Elliot

unread,
Apr 21, 2016, 5:42:38 AM4/21/16
to Cassette
To make cassette work with umbraco when cassette is in production mode, you need to add the cassette path to the umbracoReservedPaths key in Web.config.

<configuration>
   <appSettings>
      <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/cassette.axd/" />
   </appSettings>
</configuration>

The problem was with using Cassette with Umbraco after all.
I'm using Cassette 2.4.2, Umbraco  7.4.2, Visual Studio 2013, IIS Express.

Joshua

unread,
Mar 27, 2017, 10:53:32 AM3/27/17
to Cassette
Thank you, Elliot. This was exactly what I needed to get Cassette to work! Cheers :-)
Reply all
Reply to author
Forward
0 new messages