Use Bundle in MVC to package and compress js and css, and mvcbundle

Source: Internet
Author: User

Use Bundle in MVC to package and compress js and css, and mvcbundle
Step 1: Install

Install"System. Web. Optimization": Search in" NuGet"

Install.

Step 2: Configure

Add"System. Web. Optimization"Configuration

Part 3: write code

Create a Bundle file named "BundleConfig" in the "App_Start" folder, which can also be called another name.

After completion, you need to write code in "Global. asax" and execute the "RegisterBundles" method of the "BundleConfig" class.

Use @ Scripts. Render ("~ /Jsbase ") to load the compressed content.

 

It should be noted that the effect is generally not visible during debugging. In order to facilitate debugging, compression is not enabled at this time. To see the effect during debugging, change true in <compilation debug = "true" targetFramework = "4.0"/> to false.

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.