Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static Files Cannot be Found After Publishing to Linux on ARM

I got an Web-API project, based on ASP.NET Core 2.1. This Web-API has to deliver static files from the default wwwroot folder. This works fine with the code below (from Startup.cs) on my Windows machine.

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseMvc()
        .UseStaticFiles();
    }
}

But when I publish the project for Linux on ARM (dotnet publish -r linux-arm) and pushing it to the test system, the static files cannot be retrieved by the browser. The Server returns always HTTP 404, no matter how the files are named and of course I respect upper and lower case on Unix systems, so it should not be realted to Asp.Net Core Web Application Static Files Gives 404 on Linux.

The wwwroot dir content is readable by the server process. I tested this by using File.ReadAllText(<full path to file in wwwroot>).

The server only runs on localhost and therefore the project does not use other servers, like ngingx.

like image 806
user2154065 Avatar asked Oct 15 '25 20:10

user2154065


1 Answers

I think I found out, what I did wrong. I started the Web-API by using the full path. Instead, I had to switch to the application directory first.

Working:

cd /home/myuser/testapp
./testapp

Not working:

/home/myuser/testapp/testapp

I did not change anything else and I can reproduce this, so switching to the app dir first, seems to be a must.

like image 140
user2154065 Avatar answered Oct 18 '25 09:10

user2154065



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!