Not allowed to load local resource image error in browser console
Trying to load an image into a view with the path in the filesystem. I'm storing the images in the wwwroot folder. Is there a way around this error? I read I should set up a HTTP server on my computer but I have no idea how.
9 Replies
How are you trying to load it?
just the src attribute in the img tag
<img src="~/images/cat.png" />
?and it comes from the controller
@Model.imagenmpaths[0]
It's a list of strings each being a pathWhat sort of a path?
Absolute?
Relative?
it's absolute to my computer
Well that's your issue, then
wwwroot
maps to /
So if your images are in wwwroot/images
use relative paths from /images
ooooh so as far as the app is concerned wwwroot is literally the root of it's filesystem?
it is in the name
:picard_facepalm:
Yep lol
wwwroot
is where you place your robots.txt
, favicon.ico
, etc
So they get served from https://mywebsite.tld/favicon.ico
etc