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

asp.net – Do Bundles优先于Routing吗?

发布时间:2020-12-16 06:50:25 所属栏目:asp.Net 来源:网络整理
导读:如果我有一个捆绑包如: bundles.Add(new ScriptBundle("~/foo/bar").Include( "~/Scripts/foo.js")); 以及如下的路线: routes.MapRoute( "Foo",// Route name "foo/bar",new { controller = "Foo",action = "Bar" }); 哪一个优先? 浏览器会返回ScriptBund
如果我有一个捆绑包如:

bundles.Add(new ScriptBundle("~/foo/bar").Include(
                        "~/Scripts/foo.js"));

以及如下的路线:

routes.MapRoute(
  "Foo",// Route name
  "foo/bar",new
  {
     controller = "Foo",action = "Bar"
  });

哪一个优先?

浏览器会返回ScriptBundle还是ActionResult?

解决方法

如果您是 read this post,则建议捆绑路由(url)优先:

Clearly the default route with /content/css path matches the css action but the bundling framework will override the http handler.

该帖子还建议为所有捆绑路径添加前缀“捆绑”的约定.例如:

bundles.Add(new ScriptBundle("~/bundle/foo/bar").Include(
                    "~/Scripts/foo.js"));

上面引用的帖子在this tutorial中链接,其底部附近有一个名为“Bundle Considerations”的部分可能会引起关注.

(编辑:李大同)

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

    推荐文章
      热点阅读