Adding bundling to your Bootstrap projectBecause we created an empty ASP.NET MVC site, the necessaryreference for adding bundling was not automatically added to our project. Luckily, this can easily be added by using the NuGet Package Manager Consoleas follows:1. Open the Package Manager Consolewindow and enter the following command:install-package Microsoft.AspNet.Web.Optimization2. This will install the Microsoft.AspNet.Web.OptimizationNuGet package as well as all the packages it has dependencies on. These dependencies are as follows:° Microsoft.Web.Infrastructure° WebGrease° Antlr° Newtonsoft.Json3. After the NuGet packages have been installed successfully, create a new static class called BundleConfiginside the App_Startfolder.4. Inside this class, we'll create a new static method called RegisterBundles, which accepts a parameter called bundles, whose type is a BundleCollectionobject. The code for the class is as follows:public class BundleConfig{public static void RegisterBundles(BundleCollection bundles){bundles.Add(new ScriptBundle("~/bootstrap/js").Include("~/js/bootstrap.js","~/js/site.js"));bundles.Add(new StyleBundle("~/bootstrap/css").Include("~/css/bootstrap.css","~/css/site.css"));}}Bundles come in the following two types:° ScriptBundle° StyleBundle
đang được dịch, vui lòng đợi..
