Reputation: 43
I have created an empty MVC
project in VS 2012
, there were no files of Jquery CSS by default so i have copied all the Script and CSS file into my Script file and then i Have download System.Web.Optimization NuGets , after that i have create a bundle in my BundleConfig.cs
file . the code and reference file file are ok then I render the script in my view like that
@System.Web.Optimization.Scripts.Render("~/bundles/jquery")
as only Scripts.Render()
don't work so i give full name space of the Render Method
but Still my code is not working in My empty MVC project ,although I tested the same code in my MVC Internet Project which is working fine , I have also tested the Configuration Debug="false"
, but still my bundle not working and simple jquery file reference is working fine . what i am missing . I think all the problem is in Empty project which is missing some files or code to be written manually.
Upvotes: 3
Views: 3473
Reputation: 124
You need to create a Bundle Configuration Class:
namespace DemoApp
{
public class BundleConfiguration
{
public static void RegisterBundles(System.Web.Optimization.BundleCollection bundles)
{
bundles.Add(
new System.Web.Optimization.ScriptBundle("~/bundles/jquery")
.Include("~/Scripts/jquery-1.9.0.js")
);
}
}
}
And then, in the global.asax.cs
DemoApp.BundleConfiguration.RegisterBundles(System.Web.Optimization.BundleTable.Bundles);
Upvotes: 7