Chapter 4 bundle and Chapter 4 bundle
----------------------------------------------
Note: This is the last article in the current series. You are not required to learn about mobile devices, WEB APIs, and other content. A practical project will be developed later.
----------------------------------------------
I. Script and style bundle
Location:/App_Start/BundleConfig. cs
Namespace:System. Web. Optimization
The RegisterBundles static method is called by the Application_Start method in Global. asax when the application is started for the first time.
BundleConfig. RegisterBundles (BundleTable. Bundles)
When creating a new bundle, it is to create an instance of the StyleBundle or ScriptBundle class and reference the bundle path through the constructor parameters.
To prevent conflicts, the safest way is ~ /Bundles or ~ /Content as the starting path.
Custom bundle Configuration:
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/*.css")); bundles.Add(new ScriptBundle("~/bundles/clientfeaturesscripts").Include( "~/Scripts/jquery-{version}.js", "~/Scripts/jquery.validate.js", "~/Scripts/jquery.validate.unobtrusive.js", "~/Scripts/jquery.unobtrusive-ajax.js" ));
Tip: complilation in web. config. true indicates the regular version, and false indicates the compressed version.
Note:When the MVC Framework processes {version} in the bundle, it intelligently ignores the intelliisense file and ensures that there is only one version of JQuery In the Scripts folder.
Use a bundle:
<!DOCTYPE html> @Scripts.Render("~/bundles/clientfeaturesscripts")
@RenderSection("scripts", required: false)</body>
Use the Scripts section:
@section scripts{ <script src="~/Scripts/Home/MakeBooking.js" type="text/javascript"></script>}
Source code: http://yunpan.cn/ccbVkY7qzC7ID access password 077a