Image.ImageUrl

  • Thread starter Thread starter Thomas Satzinger
  • Start date Start date
T

Thomas Satzinger

Hallo.,

i just encounterd a strange thing which i cannot resolve.

I am saving a bitmap created in memory to the asp temp folder (asp.net 2.0)
this works fine, and i don´t want to create an extra folder in my
application, so i don´t need my people giving that folder the asp
permissions.

Ok, my JPG is in the temp folder.
after saving it, i want to display it in a image control, at a later time i
need it for a report generation

my problem is that the path name contains whitespaces, which i found out the
imageurl does not like at all.


example
this.image.ImageUrl = @"C:\TestFolder/image.jpg";

this.image.ImageUrl = @"C:\Test Folder/image.jpg";



The 1st statement would display the image, the second not....of course the 2
folders exist with the image in them.



Are there any solutions for that?

Thanks

Thomas
 
Spaces need to be encoded. For this you could use Server.URLEncode.
Be aware though that you need to use a URL to the image, not a local path
like you showed in your example. If you use a local path it will work when
tested on the local server but it will not work from any other client
machine.
 
Hi,

thanks for the tip, but it does not work..

i tried this.image.ImageUrl = Server.UrlEncode(@"C:\Test Folder/image.jpg");

and i still do not get the image displayed...

The path shown here is just a sample...

Thomas
 
I suggest you to user Server.MapPath to have site relative path, so if
your image is in /pictures of your site you use this:

this.image.ImageUrl = Server.UrlEncode(Server.MapPath(pictures/image.jpg));

It your images are stored out of your site path, you may be give a look
to http handlers...
 
Back
Top