Reputation: 31
I have an ASP.Net Core app that also uses Angular. On my local machine, it is able to serve static files such as js and images. When deploying to Azure, calls to static files returns the default route (which retrieves the Angular app default page.)
In my Startup.cs, I use "app.UseStaticFiles". This works locally.
My Startup.cs is found here.
Can this be a configuration issue with Azure? Or some logic that's present in Development environment but not in Production?
Upvotes: 3
Views: 4499
Reputation: 76
I have the following check-list:
Check the static files property "Copy to Output Directory" set to "Copy Always".
Check app.UseStaticFiles()
has been called in Configure()
method of Startup.cs
For Linux: call the method UseStaticFiles()
as:
app.UseStaticFiles(new StaticFileOptions() {
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"))
});
Upvotes: 1
Reputation: 496
Just had this issue and the problem was the ClientApp/dist folder on the Linux host did not have the correct permissions.
Make sure the ClientApp/dist folder has the correct permissions so the .NET Core process can access the folder properly. In my case I was missing the "enter" permission so my application fell back to the wwwroot folder.
I ran the following command to set the permissions correctly on all directories in my app root.
find /path/to/your/app -type d -exec chmod 755 {} \;
Upvotes: 0
Reputation: 3697
For anyone else hitting this problem where UseStaticFiles actually is in the startup, my problem was simple: my subfolder files were not marked as CopyAlways (to output folder).
Upvotes: 4