Core - 404 file not found on a image, CSS, Javscript or another static file?

If all your files in your wwwroot (or whatever you call your web root) folder gives you a 404. Then you have most likely misconfigured your webhost.

First of all check that you are making a call to UseStaticFiles();. This has to be in your startup.cs file that you use to configure your webhost. The call can look like below. If you do not already have a reference to Microsoft.AspNetCore.StaticFiles, then you will need that.


A less likely reason why you get a 404. is that the static files are not placed within the webroot. It could be that the webroot is set to a different location that you first anticipated. Your webroot is configured together with your WebHostBuilder by using .UseWebRoot("YourPath");. For example:

var host = new WebHostBuilder()

I hope this helps, did I miss something? Please let me know in the comments.