The reason this isn't working is because the image is in a directory that the web server doesn't have access to. So if the image control tries to retrieve the image from the server it wont be able to.
There's a couple of solutions to this problem.
The first is to move the image into a temporary images folder that is on the web server (say in the website) so that the browser can download it.
The second is to implement an ASPX page that retrieves the image (as a stream) and writes it to the Response.OutputStream.
This ASPX page will not return HTML which is what is returned by default..and is expected by the web browser. You need to change the Response.ContentType to "image/jpg" to indicate to the browser that you are sending an image instead.
There is no asp code in this page...it's just pure server-side .NET code that retrieves the image (probably based on a parameter that is provided when the page is called) and writes that image to the stream.
For example, all that would be in your ASPX page would be the following to return the full size image (VB.NET code):
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
-
-
'Changing the page's content type to indicate the page is returning an image
-
Response.ContentType = "image/jpg"
-
-
'Retrieving the name of the image
-
Dim imageName = Request.QueryString("imgName")
-
Dim path = ""D:\DirectoryPath\"+imgName
-
-
If String.IsNullOrEmpty(imageName) = False Then
-
'Retrieving the image
-
Dim fullSizeImg As System.Drawing.Image
-
fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(path))
-
-
'Writing the image directly to the output stream
-
fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg)
-
-
'Cleaning up the image
-
fullSizeImg.Dispose()
-
End If
-
End Sub
This code would be in a page called, say, GetImage.aspx ....
Now, when you specify the image source for the ImageControl you use "GetImage.aspx?imgName=Gorilla.jpg"
For example, in your page you would have:
- <asp:Image ID="Image1" ImageUrl = "GetImage.aspx?imgName=Gorilla.jpg" />
-Frinny