I am working on ASP.NET MVC 4
application. I want to make my own bundle containing .js
files which I will use for validation but for some reason it's not working. Just to mention - if I render all my scripts in a given view everything is working fine like:
@Scripts.Render("~/Scripts/jquery-1.7.1.min.js")
@Scriptes.Render("~/Scripts/jquery.validate.min.js")
//..few more files
but I don't want to include all those scripts each time so I decided to make my own bundle. The steps I made are:
- In
BundleConfig.cs
I have this :
public static void RegisterBundles(BundleCollection bundles)
{
//The defaults bundles
bundles.Add(new ScriptBundle("~/bundles/customval").Include(
"~/Scripts/jquery-1.7.1.min.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.unobtrusive-ajax.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js"));
}
Then I check my Global.asax
where I have this :
BundleConfig.RegisterBundles(BundleTable.Bundles);
and then in my view I just try :
@Scripts.Render("~/bundles/customval")
and FireBug
is saying that no JavaScript is load for this page.
I use custom _Layout
page and I wonder if I have to add something there. I added:
@RenderSection("scripts", required: false)
in my _Layout
but it doesn't seem to solve something. So what am I missing to make my bundles working?