简体   繁体   中英

MVC4 bundling route exclusion

I make use of the bundling features in MVC4 by calling bundles.EnableDefaultBundles(); , this allows me to browse to http://website.com/content/css which outputs a singular file of all the CSS files in the /content directory - great.

The issue is I have the following route which loads a blog post from the DB by title: /post/{anything} and in this case {anything} is css (for arguments sake, I can't change it) so the bundling is getting confused and trying to bundling everything in the post directory, which doesn't exist.

Is there any way to exclude a particular URL format or route from being bundled? I think not calling EnableDefaultBundles() would work but does that mean I would have to create bundles for everything manually?

Are you using an old version of the Optimization package? EnableDefaultBundles was removed prior to 1.0. You can still accomplish the equivalent of that method by adding the equivalent js/css DynamicFolderBundles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM