无法加载资源;服务器响应状态为404 - bundles / jquery - MVC

时间:2017-07-14 16:01:48

标签: asp.net .net asp.net-mvc twitter-bootstrap asp.net-mvc-4

我在MVC ASP.net中使用捆绑

这是我的BundleConfig类。  公共类BundleConfig     {

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.IgnoreList.Clear();

        bundles.Add(new ScriptBundle("~/bundle/jquery").Include(
                    "~/Scripts/jquery-1.9.1.js"));

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

        bundles.Add(new StyleBundle("~/bundle/css").Include(
                    "~/Content/bootstrap.min.css",
                    "~/Content/bootstrap.css"));

    }
}

_Layout.cshtml 我在这里渲染包

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/bundle/css")
</head>
<body>
    @RenderBody()
    @Scripts.Render("~/bundle/jquery")
    @Scripts.Render("~/bundle/js")
</body>
</html>

在运行我的应用程序时,我在浏览器控制台中出错

无法加载资源:服务器响应所有捆绑包的状态为404(未找到)

感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

您是否正在注册捆绑包(Global.asax):

protected virtual void Application_Start() {
   BundleConfig.RegisterBundles(BundleTable.Bundles);
}