MVC bundle (dressing) CSS or JS file

Source: Internet
Author: User

When you previously wrote an ASP. NET Web page, many style files or JavaScript files, such as the reference statement for the opening brace, are referenced in the


Now in an MVC application, you can use bundles to bundle together and find the App_start directory under the Solution Explorer window application. Under this directory, create a class named "BundleConfig.cs" and modify the Namespace:Insus.NET



The name of the blue underline in the #11 line will be the name of the View app. Next, we open the Global.asax.cs file, divided into three steps, the first is to refer to namespace, because just write BundleConfig.cs class, is used Insus.net namespace; the second step is to refer to another namespace "System.Web.Optimization" because the registration parameter bundletable is under this namespace.



The third step is to write the #21 line code:

Bundleconfig.registerbundles (Bundletable.bundles);



Once all is configured, you can use it in the view's file or local file.



The last thing to add is the bundle JS file example:


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.