Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net mvc Bundle.IncludeDirectory example?

Tags:

Hi Can anyone give me an example on how to use Scriptbundle method IncludeDirectory for Javascripts, not able to get how to write the search pattern string , Is it regex?

bundles.Add(new ScriptBundle("~/bundles/customjs").IncludeDirectory(                 "~/Scripts/Custom",?); 
like image 493
Rameez Ahmed Sayad Avatar asked Mar 25 '13 13:03

Rameez Ahmed Sayad


People also ask

What is bundling in MVC with example?

Bundling and Minification are two performance improvement techniques that improves the request load time of the application. Most of the current major browsers limit the number of simultaneous connections per hostname to six. It means that at a time, all the additional requests will be queued by the browser.

How do I bundle a script in MVC?

You can create style or script bundles in BundleConfig class under App_Start folder in an ASP.NET MVC project. (you can create your own custom class instead of using BundleConfig class, but it is recommended to follow standard practice.)

How will you implement bundling and minification in MVC?

To enable bundling and minification, set the debug value to "false". You can override the Web. config setting with the EnableOptimizations property on the BundleTable class. The following code enables bundling and minification and overrides any setting in the Web.


1 Answers

You can write like this:

bundles.Add(new ScriptBundle("~/bundles/customjs").IncludeDirectory(                 "~/Scripts/Custom","*.js")); 

If you want for example javascript.

You can read more here: http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

like image 156
freshbm Avatar answered Sep 19 '22 17:09

freshbm