title: Why is MVC4 @Styles.Render() not behaving as expected in debug mode
body: <p>I am implementing the bundling and minification support in MVC4 and setting it up so it can compile my Bootstrap .less files automatically for me.  I have the following code in my BundleConfig.cs file</p>
  
  <pre><code>public class BundleConfig
  {
      public static void RegisterBundles(BundleCollection bundles)
      {
          // base bundles that come with MVC 4
  
          var bootstrapBundle = new Bundle("~/bundles/bootstrap").Include("~/Content/less/bootstrap.less");
          bootstrapBundle.Transforms.Add(new TwitterBootstrapLessTransform());
          bootstrapBundle.Transforms.Add(new CssMinify());
          bundles.Add(bootstrapBundle);
      }
  }
  </code></pre>
  
  <p>The TwitterBootsrapLessTransform is as follows (it is more complicated than I would like because of the need to import the sub .less files into dotLess)</p>
  
  <pre><code>public class TwitterBootstrapLessTransform : IBundleTransform
  {
      public static string BundlePath { get; private set; }
  
      public void Process(BundleContext context, BundleResponse response)
      {
          setBasePath(context);
  
          var config = new DotlessConfiguration(DotlessConfiguration.GetDefault());
          config.LessSource = typeof(TwitterBootstrapLessMinifyBundleFileReader);
  
          response.Content = Less.Parse(response.Content, config);
          response.ContentType = "text/css";
      }
  
      private void setBasePath(BundleContext context)
      {
          BundlePath = context.HttpContext.Server.MapPath("~/Content/less" + "/imports" + "/");
      }
  }
  
  public class TwitterBootstrapLessMinifyBundleFileReader : IFileReader
  {
      public IPathResolver PathResolver { get; set; }
      private string basePath;
  
      public TwitterBootstrapLessMinifyBundleFileReader(): this(new RelativePathResolver())
      {
      }
  
      public TwitterBootstrapLessMinifyBundleFileReader(IPathResolver pathResolver)
      {
          PathResolver = pathResolver;
          basePath = TwitterBootstrapLessTransform.BundlePath;
      }
  
      public bool DoesFileExist(string fileName)
      {
          fileName = PathResolver.GetFullPath(basePath + fileName);
  
          return File.Exists(fileName);
      }
  
      public byte[] GetBinaryFileContents(string fileName)
      {
          throw new System.NotImplementedException();
      }
  
      public string GetFileContents(string fileName)
      {
          fileName = PathResolver.GetFullPath(basePath + fileName);
  
          return File.ReadAllText(fileName);
      }
  }
  </code></pre>
  
  <p>On my base _Layout.cshtml page I attempted to render the css files by doing this</p>
  
  <pre><code>@Styles.Render("~/bundles/bootstrap");
  </code></pre>
  
  <p>as is suggested by the <a href="http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification" rel="noreferrer">mvc tutorial</a> but the file the client browser ends up requesting is </p>
  
  <pre><code>http://localhost:53729/Content/less/bootstrap.less
  </code></pre>
  
  <p>which causes an error.  If I put the following link into by base layout page it works as expected.</p>
  
  <pre><code>&lt;link href="~/bundles/bootstrap" rel="stylesheet" type="text/css" /&gt;
  </code></pre>
  
  <p>Why isn't @Styles.Render() behaving in the same way in debug mode?  It works in release mode.  I can understand how you don't want it bundling and minifying in debug but how can I force this bundle to work the same way always?</p>