Images not loading when deploying website in IIS
The images used on the website are stored here (in the "Pictures" folder) -
And the images are referenced this way -
<img src="@Url.Content("/Images/greenDot.png")" style="margin-right: 10px;"/>
When I run the website on my local machine, all images are loaded fine. But when I deploy it to IIS and run this site, none of the images are loaded.
Errors -
Failed to load resource: the server responded with a status of 404 (Not found) http://54.234.60.214/Images/Logo_Innosolv.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://54.234.60.214/Images/Icons/bid.png
What's the problem? Move images to a different folder or change the way you link to them in views?
source to share
I didn't know that the website was deployed as a web application on a pre-existing website. Thus, the images had to be obtained from
http://54.234.60.214/IBeam_2/Images/Logo_Innosolv.jpg
Instead
http://54.234.60.214/Images/Logo_Innosolv.jpg
So, I changed the path to
<img src="~/Images/Logo_Innosolv.jpg" style="margin-right: 10px;"/>
Now it works.
source to share
Can I change the way I refer to them in views?
Yes, of course, you must change the image path to match your deployment directory structure. Check if you have added the correct relative or absolute path, whichever is right in your website.
OR
You may not have enabled IIS to display images. You can do it as stated in this link
If you load images using css you should check if this was the problem.
source to share