How can access image from folder from web api core? I am doing as below
https://localhost:44344/Uploaded_Documents/IMG_20190314_205925_3be1d2b3-3bac-4184-8468-995d58d5ff80.jpg
But it is giving below error.
Me configuration is like below.
Image path is like below.
How can I access this image from browser in web api core ?
If you would like to access your file out of wwwroot
folder,you need to configure the Static File Middleware as follows:
app.UseStaticFiles();// For the wwwroot folder
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Uplodaed_Documents")),
RequestPath = "/Uplodaed_Documents"
});
//Enable directory browsing
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Uplodaed_Documents")),
RequestPath = "/Uplodaed_Documents"
});
app.UseMvc();
You could refer to asp.net core static files Serve files outside of web root
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With