未找到asp.net bundler“webpage / content / js”

时间:2014-04-08 14:51:12

标签: javascript asp.net c#-4.0 razor bundles

我只浏览了大量的谷歌搜索页面以解决这个问题,但看起来每个页面都是独一无二的。我的页面来源显示该包以其应该的方式捆绑

 <script src="/Content/js?v=N2f3Y-Z24wBpC67A34qPxjK1CR3eY83Yijs13VtHOwI1"></script>

,但浏览器(chrome)开发工具表示无法加载它:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53608/Content/js/

而且,如果我点击脚本src链接,我也会收到微软生成的消息,说明资源缺失或找不到。

我得到其他捆绑(样式)加载好,我想,我错过了我的代码布局中的一些东西,我自己无法找到问题。如果有人能指出我的错误,我真的很感激,所以这里是代码:

_Layout.cshtml

    @Styles.Render("~/Content/css")
    @Scripts.Render("~/Content/js")
    @Scripts.Render("~/bundles/jquery")

BundleConfig.cs

            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-1.9.1.js",//(tried other numbers as well)
                    "~/Scripts/jquery-ui-1.10.4.js",
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*",
                    "~/Scripts/modernizr-*",
                    "~/Scripts/itpoverlay.js"
                    ));

        bundles.Add(new StyleBundle("~/Content/css").
            Include("~/Content/bootstrap.css",
            //"~/Content/ie.css",
            "~/Content/kwicks-slider.css",
            "~/Content/style.css",
            "~/Content/custom.css",
            "~/Content/responsive.css",
            "~/Content/touchTouch.css"));

        bundles.Add(new ScriptBundle("~/Content/js").Include(
          "~/Content/js/bootstrap.js",
          "~/Content/js/forms.js",
          "~/Content/js/jquery.easing.1.3.js",
          "~/Content/js/jquery.flexslider-min.js",
          "~/Content/js/jquery.kwicks-1.5.1.js",
          "~/Content/js/jquery.preloader.js",
          "~/Content/js/superfish.js",
          "~/Content/js/jquery.js",//(default bundle v1.8.1)
          "~/Content/js/touchTouch.jquery.js"));
       BundleTable.EnableOptimizations = true;

_references.js(我真的不知道为什么会这样)

/// <reference path="jquery-1.9.1.js" />
/// <reference path="jquery-ui-1.10.4.js" />
/// <reference path="jquery.unobtrusive-ajax.js" />
/// <reference path="jquery.validate.js" />
/// <reference path="jquery.validate.unobtrusive.js" />
/// <reference path="knockout-2.1.0.debug.js" />
/// <reference path="modernizr-2.5.3.js" />

现在对于输出,捆绑包看起来很好:

    <link href="/Content/css?v=NASaW-JeM0CkSMQIcoasDpn9k7bKaEK07c7WakA1Y0k1" rel="stylesheet"/>
    <script src="/Content/js?v=N2f3Y-Z24wBpC67A34qPxjK1CR3eY83Yijs13VtHOwI1"></script>
    <script src="/bundles/jquery?v=VwkJeyosUZnIv9pTtkEir1OOQCcR7BXo1RW8kdleacU1"></script>

开发工具标记了错误列表(我想,我开始得到_reference.js可能用于的内容)是否应该捆绑?错误:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53608/Content/js/
Uncaught TypeError: Object [object Object] has no method 'live' jquery?v=VwkJeyosUZnIv9pTtkEir1OOQCcR7BXo1RW8kdleacU1:1
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53608/js/jquery.preloader.js

我希望它能够发现我的错误,如果有不清楚的地方,我会很乐意用所需信息更新问题。 谢谢,厄尼斯。

1 个答案:

答案 0 :(得分:0)

Jquery live方法在1.7中已弃用,看起来你正在使用1.9

https://api.jquery.com/live/

所以看起来你有两个选择。找出使用live方法的位置,并将其更改为使用.on()。我不能给你特定的代码,因为我不知道你是如何使用.live()

或研究使用jquery migrate

http://blog.jquery.com/2013/05/08/jquery-migrate-1-2-1-released/