Search code examples
asp.netbundling-and-minificationasp.net-optimization

Using Bundling (from Systelm.Web.Optimization) in ASP.Net WebForms causes issue


I am trying to put in some optimization into my application by using BundlesCollection in my ASP.Net 4.0 application.

My style bundle contains 6 css files. The files are included into a master page. If I remove the CSS files from master page and instead put following:

<%= Styles.Render("~/bundles/css/default") %>

I am getting following error:

The Controls collection cannot be modified because the control contains code 
    blocks (i.e. <% ... %>).

Solution

  • start the code block with <%# instead of <%=