asp.net-core-mvc - 为什么我的 ASP.NET Core MVC 应用程序在错误的 wwwroot 路径中运行?
问题描述
我的DocumenRoot
文件夹已打开/var/www/html
(CentOS 7.4)
我将 ASP.NET Core MVC 应用程序安装在子文件夹中/var/www/html/mya/app/v1
我希望通过互联网访问它
https://apps.example.com/mya/app/v1
我已将所有必需的 css、js、图像文件复制到/var/www/html/mya/app/v1/webroot
为什么它看起来总是走错路?
=== Startup.cs ===
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
== Program.cs ===
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
#if !DEBUG
.UseContentRoot(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location))
#endif
.UseUrls("http://127.0.0.1:500");
});
=== 控制台 ===
GET https://apps.example.com/lib/bootstrap/dist/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/@coreui/coreui/dist/css/coreui.min.css net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/@coreui/icons/css/free.min.css net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/@fortawesome/fontawesome-free/css/all.min.css net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/bootstrap-table/dist/bootstrap-table.min.css net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/@popperjs/core/dist/umd/popper.min.js net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/image/logo-small.png 404 (Not Found)
GET https://apps.example.com/lib/bootstrap/dist/js/bootstrap.bundle.min.js net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/@coreui/coreui/dist/js/coreui.bundle.min.js net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/lib/bootstrap-table/dist/bootstrap-table.min.js net::ERR_ABORTED 404 (Not Found)
GET https://apps.example.com/js/site.js?v=PyStcLVmxSbO176wn2m8D95rLCh75CNK1zHD1dW8f-A net::ERR_ABORTED 404 (Not Found)
解决方案
推荐阅读
- blazor - Blazorise 垂直侧边栏切换
- c# - 如何在使用的 WCF 服务中更改 URL - .net 核心
- java - Java aes解密字节缓冲区,包括填充为空字节
- c - 可以将非 void 函数指针作为 void 函数指针传递吗?
- csv - 根据命令行上的列值删除 CSV 文件的行
- python - 如何使用自动化脚本显示/隐藏 Maximo 属性值
- sqlite - 如何使用 PRAGMA 获取 SQLite 文件中的列数?
- python - 在 pandas groupby 模式下使用用户定义的函数,将其应用于多个列并将结果分配给新的 pandas 列
- google-apps-script - 是否可以以编程方式更改容器绑定脚本的云平台项目?
- c# - 当我将程序复制到新 PC 时,是否有方法让 App.Config.Settings 中的变量保持更改?