Last post Jan 24, 2020 04:05 AM by Rion Williams
Jan 24, 2020 03:05 AM|BradyleyB|LINK
Putting an image on a page should be one of the easiest things to do, right? (it was easy in 1993)
I'm baffled because I dragged the picture over to the .cshtml page and it automatically wrote it as
<img src="C:\Users\18049\source\repos\Sherlock\img\Krebs2.jpg" />
which works fine if I post it into a browser, but when I run the page it comes up as a broken image.
Jan 24, 2020 04:05 AM|Rion Williams|LINK
The primary issue here is that you are referencing a file from your local filesystem, which might work locally (since just a plain HTML file would know about adjecent files in your file system), but once you host it in a web server, you can think of it as
in a sandbox (e.g. it can only access what the "site" has access to).
If you wanted to resolve this, you'd need to create a folder relative to where your site is being hosted (e.g. if you root is wwwroot, then create a wwwroot/images folder and store your image in there). Then just reference your image relatively from that
root (e.g. src='/images/Krebs2.jpg')