Documentation version: v1 • v2
Configuration
Cassette uses code-based configuration to define asset bundles and what processing to apply to them.
Your web application can contain a public class that implements Cassette.ICassetteConfiguration.
During application start-up, Cassette will create your configuration class and call the Configure method.
Here's the outline of a configuration class:
using Cassette.Configuration;
public class CassetteConfiguration : ICassetteConfiguration
{
public void Configure(BundleCollection bundles, CassetteSettings settings)
{
// Put configuration here...
// Add bundles to the bundles collection.
}
}
The Cassette.Aspnet nuget package adds the CassetteConfiguration.cs file to your project.
Cassette settings
The CassetteSettings controls the runtime behavior of Cassette.
IsDebugingEnabled- When true, asset bundles are concatenated, minified, cached, versioned, etc.
- Default value is read from Web.config.
UrlModifier- If you need to change how Cassette generates URLs for assets and bundles, this is the place to provide your own
implementation of
Cassette.IUrlModifier. - The main use case would be prefixing URLs with a static/CDN domain name.
- Please ask in the Cassette Google Group for help with this.
IsHtmlRewritingEnabled- Defaults to
true. - When
trueCassette will buffer and rewrite page HTML output. This means that if a partial view references a stylesheet after<head>has been rendered, the required<link>can still be inserted. - Please note, this does not work in IIS when
<urlCompression dynamicCompressionBeforeCache="true"/>. You will need to disableIsHtmlRewritingEnabledif you use that feature of IIS.
Web.config
Cassette provides a optional configuration section you can add to Web.config.
<configuration>
<configSections>
<section name="cassette" type="Cassette.Configuration.CassetteConfigurationSection, Cassette"/>
</configSections>
<cassette debug="true" rewriteHtml="true"/>
</configuration>
If the debug attribute is missing then the value of <system.web>/<compilation debug="..."> is used.