首页 > 解决方案 > 为什么我的 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)

标签: asp.net-core-mvc

解决方案


推荐阅读