简体   繁体   English

MVC4捆绑路由排除

[英]MVC4 bundling route exclusion

I make use of the bundling features in MVC4 by calling bundles.EnableDefaultBundles(); 我通过调用bundles.EnableDefaultBundles();来利用bundles.EnableDefaultBundles();中的捆绑功能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. ,这使我可以浏览到http://website.com/content/css ,它输出/content目录中所有CSS文件的单个文件-太好了。

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. 问题是我有以下路线,按标题从数据库加载博客文章: /post/{anything} ,在这种情况下, {anything}css (出于参数的原因,我不能更改它),因此绑定是感到困惑,并尝试将post目录中的所有内容捆绑在一起,该目录不存在。

Is there any way to exclude a particular URL format or route from being bundled? 有什么方法可以排除捆绑的特定URL格式或路由? I think not calling EnableDefaultBundles() would work but does that mean I would have to create bundles for everything manually? 我认为不调用EnableDefaultBundles()会起作用,但这是否意味着我必须手动为所有内容创建捆绑包?

Are you using an old version of the Optimization package? 您是否正在使用旧版的Optimization软件包? EnableDefaultBundles was removed prior to 1.0. EnableDefaultBundles在1.0之前已删除。 You can still accomplish the equivalent of that method by adding the equivalent js/css DynamicFolderBundles. 您仍然可以通过添加等效的js / css DynamicFolderBundles来实现该方法的等效方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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