Image not found

C

Craig Buchanan

I have an application written in Visual Web Developer 2005 Express. It runs
on localhost:3291. I would like to include a number of images from the
/Images directory (child of wwwroot folder). Unfortuantely, the application
can't seem to see this folder. I've tried a number of paths formats,
including http://localhost:3291/Images/logo.gif, but I haven't been
successful.

Can anyone point me in the right direction?

Thanks,

Craig Buchanan
 
M

MatsL

From the url I assume you're running the cassini browser that comes
with Visual Studio. Are you sure that the images folder is a subfolder
of the folder you are running the web application from?
Try copying the Images folder to the one you are running the application
from.

//Mats
 
C

Craig Buchanan

Here is the structure:

Image folder
....wwwroot
\images

Project folder
....My Documents
\Visual Studio 2005
\WebSites
\MyApplication

Using Microsoft Visual Web Designer 2005 Express.

I would rather not have to copy the image folder if possible.

Is there another way?
 
L

Laurent Bugnion

Hi,

Craig said:
Here is the structure:

Image folder
...wwwroot
\images

Project folder
...My Documents
\Visual Studio 2005
\WebSites
\MyApplication

Using Microsoft Visual Web Designer 2005 Express.

I would rather not have to copy the image folder if possible.

Is there another way?

The folders you reference using a relative URL must be under the web
application's root.

One way to do what you want would be to read the images using a
HttpHandler or an ASPX page, and to write the image to the response
stream directly. The advantage of this is that you can read images from
anywhere on the host (assuming of course that the correct permissions
are set).

The disadvantage of this solution is that you force all image requests
to go through one URL only (as opposed to the case where each image has
its own URL). I didn't measure it, but IMHO it will be slower than the
standard way.

Something like that should give you an idea of how to make it work:

Bitmap bmpOriginal = new Bitmap( strPath );
// where strPath is the path to the image file

bmpOriginal.Save( Response.OutputStream, ImageFormat.Jpeg );
// Assuming your images are JPG

Then, you can call this with (for example)

<img src="mypage.aspx?file=myImage.jpg" />

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top