Chapter 4 bundle and Chapter 4 bundle

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.