【问题标题】:Releasing MVC 4.0 project that uses bundling(<compilation debug="false" targetFramework="4.0">)发布使用捆绑的 MVC 4.0 项目(<compilation debug="false" targetFramework="4.0">)
【发布时间】:2013-07-20 01:20:42
【问题描述】:

这是我的捆绑包:

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                "~/Bootstrap/assets/js/jquery.js"));

    bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                "~/Bootstrap/assets/js/bootstrap-transition.js",
                "~/Bootstrap/assets/js/bootstrap-alert.js",
                "~/Bootstrap/assets/js/bootstrap-modal.js",
                "~/Bootstrap/assets/js/bootstrap-dropdown.js",
                "~/Bootstrap/assets/js/bootstrap-scrollspy.js",
                "~/Bootstrap/assets/js/bootstrap-tab.js",
                "~/Bootstrap/assets/js/bootstrap-tooltip.js",
                "~/Bootstrap/assets/js/bootstrap-popover.js",
                "~/Bootstrap/assets/js/bootstrap-button.js",
                "~/Bootstrap/assets/js/bootstrap-collapse.js",
                "~/Bootstrap/assets/js/bootstrap-carousel.js",
                "~/Bootstrap/assets/js/bootstrap-typeahead.js",
                "~/Bootstrap/assets/js/bootstrap-affix.js",
                "~/Bootstrap/assets/js/application.js",
                "~/Bootstrap/assets/js/bootstrap.js"
                ));

}

以下是我的 _Layout 页面的部分内容:

@Scripts.Render("~/bundles/bootstrap")
... 

当我尝试运行此应用程序时,我收到类似这样的 js 错误

An Error has occurred in the script on this page
Object Expected
URL   http://servername/AppName/bundles/bootstrap?v=asdjisdjsincdjijadosJISJDIS_idosd 

这里问了一个类似的问题: Why is my CSS bundling not working with a bin deployed MVC4 app?

我尝试按照我引用的问题中的建议将此配置添加到我的 web.config 文件中

<modules runAllManagedModulesForAllRequests="true">
  <remove name="BundleModule" />
  <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>

我仍然遇到同样的错误。

如果有什么不清楚的地方请告诉我,我会详细说明。 谢谢

【问题讨论】:

  • 你是在你的引导包之前渲染你的 jquery 包吗?它没有显示在您的代码中
  • 你的包中的所有脚本都是第三方的吗?
  • 没有。其中一些是我的。我通过关闭捆绑“解决”了这个问题(没有真正解决它)。我计划在项目结束时启用它并回到这个问题。

标签: asp.net-mvc razor bundle


【解决方案1】:

您的应用程序中是否存在 Bundle 文件夹?

试试:

bundles.Add(new ScriptBundle("~/Bootstrap/assets/js/jquery").Include(
            "~/Bootstrap/assets/js/jquery.js"));

bundles.Add(new ScriptBundle("~/Bootstrap/assets/js/bootstrap").Include(

http://www.mvccentral.net/Story/Details/articles/kahanu/stylebundle-403-error-solved

MVC CSS not rendering in Visual Studio When debugging

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-19
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多