Unable to get Bundling / Minification to work in VS2012

I am using Visual Studio 2012 RC

I created an ASP.NET 4 web application / internet application

In the view, I have this code:

<script type="text/javascript"> $(function () { alert("Test"); }); </script> 

Despite a lengthy search, I cannot get Bundling / Minification to work. In _Layout.cshtml, I have the following. I did not do anything. Can someone please tell me what I need to do? Many thanks.

  @Styles.Render("~/Content/themes/base/css", "~/Content/css") @Scripts.Render("~/bundles/modernizr") @*This line Does Not Work*@ @Scripts.Render("~/Scripts/js") @*This Line Does Work*@ <script type="text/javascript" src="~/Scripts/jquery-1.7.2.js"></script> 
+7
source share
1 answer

First create a script package and add the necessary scripts.

 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-1.*", "~/Scripts/jquery-ui-1.8.20.js")); } 

Then use @ Scripts.Render in your page:

 @Scripts.Render("~/bundles/jquery"); 

Note that the path I specified in the ScriptBundle above is the same path that I used in Scripts.Render.

Follow this article, http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification .

+4
source

All Articles