Image.ImageUrl is correct but image is not displayed...

Posted 14 September 2012 - 06:39 AM

Hi there Gurus!

I have an Image control on my form. At run time i assign an URL that is correct, i know that it is correct because i display that myImg.ImageUrl in a label and i see - C:\Inetpub\RTVSearchWords\germany\tempLogos\myPic.jpg. this path really exists on the server.
"germany" is a root directory for my website.

The logic is simple: Image should only appear at certain circumstance. Otherwise the control should be there but with a red 'X' at the top left corner. If image should be there then of course image control should display it but it wont ...
but image control is not showing red 'X' either, it shows some kind of an icon at the top left corner. It seems that image control actually receives URL but cant show it. If i view page source then i see that this img get correct url.

Struggling whole day already without any success. I wonder if it could be IIS issue. For example some configuration that blocks images?...

Re: Image.ImageUrl is correct but image is not displayed...

Posted 18 September 2012 - 01:05 PM

I would think that CasiOo is correct. Backslashes are correct for file paths, but URLs use forward slashes. Besides, if these images live in a folder within your site, why would you try to drill all the way down to the root and build the path back up? The folder that contains your website is the root as far as the site is concerned, so even an absolute path would start with that folder's full name (including path) inferred.

Re: Image.ImageUrl is correct but image is not displayed...

Posted 19 September 2012 - 01:53 AM

Thanks for answers guys!

You both are right that URL should start from root but on another hand actually an absolute URL is also working when binding ImageUrl. When i debug it in VS i get those images even when URL starts from C drive. But when site was deployed on a server it didn't show anything.

The problem was that this URL "C:\Inetpub\RTVSearchWords\germany\tempLogos\myPic.jpg" is correct but it is client machine relevant. Image control thought that image is on client machine and of course there were no such file or directory.

Well my goal was to display images, but since above method didn't worked i used HttpHandler and set imageUrl as a myHandler.ashx?imgID=... And that was much easier.