Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:33:59+00:00 2026-06-10T18:33:59+00:00

According to an article I read earlier by Scott Guthrie , and a video

  • 0

According to an article I read earlier by Scott Guthrie, and a video posted by Mads Kristensen, I should be able to auto-bundle/minify in ASP.net MVC 4 by replacing this:

<link href="Styles/reset.css" rel="stylesheet" type="text/css" />
<link href="Styles/normalize.css" rel="stylesheet" type="text/css" />
<link href="Styles/styles.css" rel="stylesheet" type="text/css" />

<script src="Scripts/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-validation.min.js" type="text/javascript"></script>

With this:

<link href="Styles/css" rel="stylesheet" type="text/css" />

<script src="Scripts/js" type="text/javascript"></script>

I’ve tried targeting both .Net 4.0 and 4.5 and it doesn’t seem to make a difference. I get 404 errors and the link and script tags are never directed at the bundled resources.

Did this feature get dropped from the final version?

I’d like to utilize this feature for “Themes”.


This is how I ended up implementing. Hopefully it makes sense…

 /// <summary>
 /// Render stylesheets HTML for the given theme. Utilizes System.Web.Optimization for bundling and minification
 /// </summary>
 /// <param name="themeName">Name of theme</param>
 /// <returns>HtmlString containing link elements</returns>
 public static IHtmlString RenderThemeStyles(string themeName)
 {
     IHtmlString retValue = null;

     // If no theme name is passed, return null
     if (!themeName.HasValue())
         return retValue;

     var ctxt = HttpContext.Current;
     string themePath = "~/Themes/" + themeName;
     string themeKey = themePath + "/css";

     if (ctxt.Cache[themeKey] != null)
         return (IHtmlString)ctxt.Cache[themeKey];

     // Check to see if the theme directory exists. Throw error if it does not
     string themeSysPath = HttpContext.Current.Server.MapPath(themePath);
     DirectoryInfo themeDir = new DirectoryInfo(themeSysPath);
     if (!themeDir.Exists)
         throw new ApplicationException(string.Format("Theme directory \"{0}\" does not exist", themePath));

     // Remove the old bundle if it already exists
     var old_bundle = BundleTable.Bundles.FirstOrDefault(b => b.Path == themeKey);
     if (old_bundle != null)
         BundleTable.Bundles.Remove(old_bundle);

     if (themeDir.GetFiles("*.css").Length > 0)
     {
         // If there are css files, add them to the bundler and save the rendered output to cache
         Bundle styles = new StyleBundle(themeKey).IncludeDirectory(themePath, "*.css");
         BundleTable.Bundles.Add(styles);
         retValue = Styles.Render(themeKey);
         ctxt.Cache.Insert(themeKey, retValue, new System.Web.Caching.CacheDependency(themeSysPath));
     }
     else
     {
         // If there are no css files, save empty string to cache
         ctxt.Cache.Insert(themeKey, new HtmlString(string.Empty), new System.Web.Caching.CacheDependency(themeSysPath));
     }

     return retValue;
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:34:01+00:00Added an answer on June 10, 2026 at 6:34 pm

    Yes, this feature is removed in the MVC4 RC version although I could not find the RC release notes anymore.

    Rick Anderson ‘s blog post on upgrade MVC4 beta to RC describes the process:

    Remove the “autobundling” references and create/copy a BundleConfig.cs with your bundle configs and call it from Global.asax with BundleConfig.RegisterBundles(BundleTable.Bundles);.

    Hanselman mentions some backround info about the decision:

    There’s been some significant changes to the web optimization
    (minification and bundling) framework since beta. There wasn’t enough
    control over what was bundled and in what order in the beta, so that’s
    been moved into a BundleConfig.cs (or .vb) where you have total
    control

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html article, I defnitely should. Quote Gentle, yet insistent executive summary:
According to this Wikipedia article on Google App Engine : Developers have read-only access
According to this article from Herb Sutter, one should always pick Class Specializing over
According this article , generic JPA DAO(Data Access Object) is a pretty nice pattern.
According to this article , it says: Use a delegate in the following circumstances:
According to this article , it's possible to get multiline XML comments -- instead
According to this article about writing shell extensions in .Net, inheriting the shell interfaces
I am doing a tutorial according to this article . This is basic Hello
I've got a PHP-fpm setup on nginx setup according to this article: http://interfacelab.com/nginx-php-fpm-apc-awesome/ PHP
According to HTML5Doctor's article on the dl element : <dl> can be used to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.