Jason Lie
Jason Lie

Reputation: 159

asp.net Images not loading after publishing

My images won't load after I publish my application. They do load when I'm debugging. Any idea what can cause this problem?

<a class="navbar-brand" href="@Url.Action("SearchQuery", "Search")"><img id="logo" src="~/Images/Logo.png"/></a>

Upvotes: 5

Views: 10141

Answers (7)

Andyroo
Andyroo

Reputation: 9

When a image wont load, always be sure to inspect the network tab within the dev tools. I had a problem where images with a specific folder wouldn't load after upload. Turned out that I had adblock installed on my pc and the folder was named Adverts. duh!

Upvotes: 0

chmur300
chmur300

Reputation: 1

THIS may help.

I had the same problem - image loading at debugging in VS/IIS, but not after deployment on another computer.

Did all that was advised here and elsewhere. After hours of searching and not finding any answers, I came across the most fundamental solution.

Turned out, it was my fault, being too hasty with the windows features setup.

You need to turn on static content for WWW services, as it is described in the linked answer, and as was probably mentioned in every tutorial ever, which obviously I missed.

Hope that helps someone.

Upvotes: 0

Blesson Jose
Blesson Jose

Reputation: 698

Steps to add images to be published:

1) Right click the images folder and select "Include In Project"

Include In Project

2) Now you should see Build Action: Content on the properties for the images.

enter image description here

Upvotes: 5

Ramazan Binarbasi
Ramazan Binarbasi

Reputation: 787

Maybe you do add image to your development folder (via explorer etc) but not to your project. If an image file is not included in project, this will happen.

If this is the case; please check if you can see logo.png under Images folder with an image icon in Visual Studio's solution explorer. If it's not there try checking "Show All Files" in solution explorer's toolbar. Then try right click -> Include In Project. After that, publish will copy the file to output folder.

Upvotes: 0

Willy David Jr
Willy David Jr

Reputation: 9171

Try Url.Content on your src attribute:

src="@Url.Content("~/Images/Logo.png")"

Upvotes: 1

A.M. Patel
A.M. Patel

Reputation: 334

Please check your publish code because of after your publish this image not appear in particular folder. may be issue of publish.

Upvotes: 0

PtrBld
PtrBld

Reputation: 64

Are you sure you have set the Image folder to be deployed along with your other files (Folder --> Properties --> Build Action)?

For further information please take a look at: https://msdn.microsoft.com/en-us/library/ee942158(v=vs.110).aspx#Anchor_1

Upvotes: 0

Related Questions