Documentation

Using Cassette in MVC

The Cassette Bundles helper class is in the Cassette.Views namespace. The nuget package updates the ~\Views\Web.config to make this namespace available in view pages.

Note: If you are using MVC Areas, then you need to edit the Web.config for each area in a similar manner.

<configuration>
    ...
    <system.web.webPages.razor>
        <pages>
            <namespaces>
                ...
                <add namespace="Cassette.Views"/>
            </namespaces>
        </pages>
    </system.web.webPages.razor>
    ...
</configuration>

Cassette in Razor views

Use code blocks to define references. Use inline expressions for the render calls.

@{
    Bundles.Reference("scripts/lib/jquery.js");
    Bundles.Reference("scripts/app/home.js");
}
<!DOCTYPE html>
<html>
<head>
    <title>Web App</title>
    @Bundles.RenderStylesheets()
</head>
<body>
    ...
    @Bundles.RenderScripts()
</body>
</html>

Cassette in ASPX views

Use aspx code blocks to defined references. Use aspx expressions for the render calls.

<%@ Page Language="C#" %>
<%
    Bundles.Reference("scripts/lib/jquery.js");
    Bundles.Reference("scripts/app/home.js");
%>
<!DOCTYPE html>
<html>
<head>
    <title>Web App</title>
    <%: Bundles.RenderStylesheets() %>
</head>
<body>
    ...
    <%: Bundles.RenderScripts() %>
</body>
</html>