加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – ASP MVC – 创建目录路径而不是文件路径的Bundle

发布时间:2020-12-16 03:58:59 所属栏目:asp.Net 来源:网络整理
导读:我有这个: bundles.Add(new StyleBundle("~/Content/Styles/Default").Include("~/Content/Styles/Default/Site.css")); 它创造了这个: link href="/Content/Styles/Default?v=HG5hShy6_NaqI7SUDWQuc6zijexRxZooKF4ayIgK5tY1" rel="stylesheet" 现在,我在
我有这个:

bundles.Add(new StyleBundle("~/Content/Styles/Default").Include("~/Content/Styles/Default/Site.css"));

它创造了这个:

<link href="/Content/Styles/Default?v=HG5hShy6_NaqI7SUDWQuc6zijexRxZooKF4ayIgK5tY1" rel="stylesheet">

现在,我在我的网络服务器上启用了目录浏览,当我点击该样式路径时,它将我移动到一个目录,而不是文件!为什么?

更新:我仍然无法解决这个问题,当我进入链接http:// myserver / Content / Styles / Default?v = HG5hShy6_NaqI7SUDWQuc6zijexRxZooKF4ayIgK5tY1是一个文件列表(如在ftp上)

解决方法

首先来看看这个 article

Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine
or bundle multiple files into a single file. You can create CSS,
JavaScript and other bundles. Fewer files means fewer HTTP requests
and that can improve first page load performance.

The request

HTTP://本地主机/ MvcBM_time /捆绑/ AllMyScripts V = r0sLDicvP58AIXN_mc3QdyVvVj5euZNzdsa2N1PKvb81

is for the bundle AllMyScripts and contains a query string pair
v=r0sLDicvP58AIXN_mc3QdyVvVj5euZNzdsa2N1PKvb81.

The query string v has
a value token that is a unique identifier used for caching. As long as
the bundle doesn’t change,the ASP.NET application will request the
AllMyScripts bundle using this token. If any file in the bundle
changes,the ASP.NET optimization framework will generate a new token,
guaranteeing that browser requests for the bundle will get the latest
bundle

这是如何使用文件添加目录

bundles.Add(new StyleBundle("~/jQueryUI/themes/baseAll")
    .IncludeDirectory("~/Content/themes/base","*.css"));

这是添加多个文件的方法:

bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
          "~/Content/themes/base/jquery.ui.core.css","~/Content/themes/base/jquery.ui.resizable.css","~/Content/themes/base/jquery.ui.selectable.css","~/Content/themes/base/jquery.ui.accordion.css","~/Content/themes/base/jquery.ui.autocomplete.css","~/Content/themes/base/jquery.ui.button.css","~/Content/themes/base/jquery.ui.dialog.css","~/Content/themes/base/jquery.ui.slider.css","~/Content/themes/base/jquery.ui.tabs.css","~/Content/themes/base/jquery.ui.datepicker.css","~/Content/themes/base/jquery.ui.progressbar.css","~/Content/themes/base/jquery.ui.theme.css"));

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读