I am using Visual Studio 2012 RC
I have created an ASP.NET 4 Web Application / Internet Application
In a view I have this code:
<script type="text/javascript">
  $(function () {
    alert("Test");
  });
</script>
In spite of prolonged searching I cannot get Bundling/Minification to work. In _Layout.cshtml I have the following. I have done NOTHING else. 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>
First create your script bundle, and add whichever scripts you want.
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 you page like this:
@Scripts.Render("~/bundles/jquery");
Notice that the path I specified in the ScriptBundle above is the same path I used in Scripts.Render.
Follow this article, http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With