Results 1 to 2 of 2

Thread: Why does my ASP.NET Core MVC app run in the wrong wwwroot path?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    765

    Question Why does my ASP.NET Core MVC app run in the wrong wwwroot path?

    Hi All,

    My DocumenRoot folder is on /var/www/html (CentOS 7.4)

    I install my ASP.NET Core MVC (Net Core 3.1) app in subfolder /var/www/html/mya/app/v1 (I expect to access it from internet using https://apps.example.com/mya/app/v1)

    I have copied all of required css, js, images files into /var/www/html/mya/app/v1/webroot

    Why does it look like it keeps going on the wrong path?

    Code:
    My DocumenRoot folder is on /var/www/html (CentOS 7.4)
    
    I install my ASP.NET Core MVC app in subfolder /var/www/html/mya/app/v1 (I expect to access it from internet using https://apps.example.com/mya/app/v1)
    
    I have copied all of required css, js, images files into /var/www/html/mya/app/v1/webroot
    
    Why does it look like it keeps going on the wrong path?
    
    === Startup.cs ===
    
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseRouting();
    app.UseAuthorization();
    
    app.UseEndpoints(endpoints =>
    {
         endpoints.MapControllerRoute(
         name: "default",
         pattern: "{controller=Home}/{action=Index}/{id?}");
    m});
    
    == 
    
    
    == Console Output
    
    === Console ===
    
    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)

  2. #2
    Hyperactive Member
    Join Date
    Jun 2019
    Posts
    315

    Re: Why does my ASP.NET Core MVC app run in the wrong wwwroot path?

    ASP.NET Core apps are using own web server (code name Kestrel) to run cross-platform (Linux, MacOS, Windows). The path /var/www/html/ looks more like Apache web server one. So you have two web servers running on the system.

    First, don't copy ASP.NET Core compiled app in Apache www directory. It runs standalone somewhere else in your system (ask your administrator where to put it).

    The configuration of your ASP.NET Core app will run web server on non-standard port like 5001. To access it from public port 80 or 443 you have to create proxy configuration in your apache config (e.g. conf/httpd.conf or conf/extra/httpd-vhosts.conf). This "proxy" will forward requests to given path (e.g. https://yourhost/aspnetapp/) to internal Kestrel web server at https://localhost:5001/aspnetapp.

    Using subdirs in proxy may cause some problems if your ASP.NET Core app expects and works with different directory names as html may contain wrong links to your app root dir, not to proxied one.

    You can read more on Microsoft docs web site: Host ASP.NET Core on Linux with Apache.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width