MVC4捆绑使用Scripts.Render放缓时, [英] MVC4 Bundling slow when using Scripts.Render

查看:393
本文介绍了MVC4捆绑使用Scripts.Render放缓时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提供一个简单的页面呈现捆绑的脚本时,我的asp.net MVC4 Web项目,运行速度非常慢。然而,当我使用'硬codeD脚本标签与虚拟束路径的源属性页面上则表现要好得多:

My asp.net MVC4 web project is running very slowly when serving a simple page that renders bundled scripts. However, when I use a 'hardcoded' script tag on the page with the source attribute of the virtual bundle path then performance is much better:

@Scripts.Render("~/bundles/scripts")                            ~ 4 seconds

VS

<script src='@Scripts.Url("~/bundles/scripts")'></script>       < 1 second

我的 BundleConfig.cs 并没有特殊的配置,这正是因为它似乎:

My BundleConfig.cs has no special configuration, this is exactly as it appears:

bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
    "~/Scripts/jquery-1.7.2.min.js",
    "~/Scripts/jquery.validate.min.js",
    "~/Scripts/jquery.validate.unobtrusive.js",
    "~/Scripts/jquery-ui-1.9.0.custom.min.js",
    "~/Scripts/bootstrap.min.js",
    "~/Scripts/bootstrap-modal.js",
    "~/Scripts/bootstrap-dropdown.js",
    "~/Scripts/bootstrap-tooltip.js",
    "~/Scripts/bootstrap-typeahead.js",
    "~/Scripts/bootstrap-transition.js",
    "~/Scripts/bootstrap-popover.js"));

我的的web.config 即使被配置在调试优化,但我曾尝试在Release模式下运行,仍然得到同样的结果:

My web.config is even configured to optimize in Debug but I have tried running in Release mode and still get the same result:

<compilation optimizeCompilations="true" debug="false" targetFramework="4.0" />

任何想法,为什么 Scripts.Render 很慢?

Any ideas why Scripts.Render is so slow?

推荐答案

的问题是与我已经安装了过时的包。一个简单的更新封装在包管理器控制台,我从去

The problem was with the outdated package I had installed. A simple Update-Package in package manager console and I went from

<package id="Microsoft.AspNet.Web.Optimization"
    version="1.0.0-beta2" targetFramework="net40" />

<package id="Microsoft.AspNet.Web.Optimization"
    version="1.0.0" targetFramework="net40" />

现在 Scripts.Render()是peforming好得多: - )

Now Scripts.Render() is peforming much better :-)

这篇关于MVC4捆绑使用Scripts.Render放缓时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆