Unable to get Bundling/Minification to work in VS2012

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.

链接地址: http://www.djcxy.com/p/60338.html

上一篇: 如何预览删除

下一篇: 无法获得捆绑/缩小在VS2012中工作