加载资源404(未找到)失败-文件位置错误

Failed to load resource 404 (Not Found) - file location error?

本文关键字:失败 文件 位置 错误 资源 加载      更新时间:2023-09-26

我正在构建一个Angular 2应用程序,我刚刚升级到Net Core RC2。在升级之前,我的网页会显示得很好,但现在我在我的Chrome开发工具控制台得到错误:

    Failed to load resource: the server responded with a status of 404 (Not Found): 
http://localhost:5000/lib/bootstrap/dist/js/bootstrap.min.js
    Failed to load resource: the server responded with a status of 404 (Not Found): 
http://localhost:5000/lib/bootstrap/dist/css/bootstrap/bootstrap.min.css

我有bootstrap在我的包。3.3.6版本的Json文件。我用npm install命令安装它。它正确地安装在我的Visual Studio项目中。这些文件位于:

project -> node_modules -> bootstrap -> dist -> js -> bootstrap .min.js

project -> node_modules -> bootstrap -> dist -> css -> boostrap.min.css

我的gulpfile有这样一段:

var config = {
libBase: 'node_modules',
lib: [
    require.resolve('bootstrap/dist/css/bootstrap.min.css'),
    require.resolve('bootstrap/dist/js/bootstrap.min.js'),
    path.dirname(require.resolve('bootstrap/dist/fonts/glyphicons-halflings-regular.woff')) + '/**',
    require.resolve('jquery/dist/jquery.min.js'),
    require.resolve('chart.js/dist/Chart.bundle.min.js')
]

};

我还看到一个_Layout中对bootstrap.min.js的引用。cshtml文件:

<!doctype html>
<html lang="">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Homepage WebDev</title>
    <base href="/" />
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</head>
<body>
    @RenderBody()
    @RenderSection("scripts", required: false)
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="~/lib/chart.js/dist/Chart.bundle.min.js"></script>
</body>
</html>

我是网络开发的新手,所以我不完全确定发生了什么。有人能给我指个正确的方向吗?

看起来您给出的路径中没有任何引导文件。

href="~/lib/bootstrap/dist/css/bootstrap.min.css"

确保文件在那里存在,否则将文件指向正确的路径,在您的情况下应该是

href="~/node_modules/bootstrap/dist/css/bootstrap.min.css"