El paquete personalizado en MVC 4 no se procesa
Estoy trabajando en
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:
BundleConfig.csTengo esto :
public static void RegisterBundles(BundleCollection bundles)
//The defaults bundles
"~/Scripts/jquery-1.7.1.min.js", "~/Scripts/jquery.validate.min.js", "~/Scripts/jquery.unobtrusive-ajax.min.js", "~/Scripts/jquery.validate.unobtrusive.min.js"));
Entonces reviso mi
Global.asax where I have this :
and then in my view I just try :
I use custom
_Layout page and I wonder if I have to add something there. I added:
@RenderSection("scripts", required: false)
_Layout but it doesn't seem to solve something. So what am I missing to make my bundles working?
preguntado el 05 de diciembre de 13 a las 10:12
You're probably running in
DEBUG mode. in this mode
.min.js files are ignored (as they're only intended for Production use).
It would be best to include the non-minified (sometimes suffixes with
.debug.js) versions, then on
RELEASE mode the Optimization Framework will Bundle and Minify it for you automatically (unless you specify otherwise).
I have had to add:
BundleTable.EnableOptimizations = false;
at the end of the RegisterBundles method. In my old age :) I can't remember exactly what the issue was but it has to do with the .min files and debugging if memory serves me right.
The @RenderSection("scripts", required: false) is to allow you to have a special scripts section (optional in your case) defined in each view and have it rendered in the same place in every page that uses the _layout file.
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas .net asp.net-mvc-4 bundle or haz tu propia pregunta.