Quantcast
Channel: ASP.NET Core can't see images when acceding by browser - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Ryan for ASP.NET Core can't see images when acceding by browser

$
0
0

If you would like to access your file from your own folder img located in the root of the project instead of the default wwwroot folder ,you need to configure the Static File Middleware in startup.cs Configure method like below:

app.UseStaticFiles();// For the wwwroot folderapp.UseStaticFiles(new StaticFileOptions    {        FileProvider = new PhysicalFileProvider(            Path.Combine(Directory.GetCurrentDirectory(), "img")),        RequestPath = "/img"    });app.UseRouting();//other middlewares

Refer to https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2#serve-files-outside-of-web-root


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>