cagin
cagin

Reputation: 5930

Image control doesn't show image

I have an Image control in my asp.net page. I gave an image url from properties window but when I run my application, the image doesn't shown. The source code is here:

 <asp:Image ID="imgMain" runat="server" 
        ImageUrl="~/ProductImages/Larges/Hydrangeas.jpg" />

And I am sure of the path is correct. I can see the picture on file explorer when I copy the image url from browser's source code.

Do you have any idea?

Upvotes: 0

Views: 943

Answers (2)

Paul Hope
Paul Hope

Reputation: 11

I found that since my website was being launched as the Default Web Site, I had to also add the file in C:\inetpub\wwwroot**. ** represents the directory structure for the file location. Once I did that, the image then displayed via the browser.

Upvotes: 1

user1429080
user1429080

Reputation: 9166

I'm assuming that your original URL in the question is correct.

Without knowing anything more, I would start by checking if it's an autorization issue:

  • When you debug this issue, are you logged in to the site? If not try to log in first.
  • When logged in, check that the logged in user is authorized to access content from the path in question.

Also try to copy the URL on the image tag in the rendered page and paste it directly in the address bar of your browser. What happens?

Upvotes: 0

Related Questions