access images outside the web path
How can i d开发者_Python百科isplay images that are saved outside the the WebSite folder. Any example would be greatly appreciated?
To do this you could write a handler that would know the location of your files then use the Response.WriteFile
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.writefile.aspx to get the file and write it to the output stream.
You would need to set the content type first so the browser knows what you're doing.
Similar to what is being done in this example: http://www.dotnetperls.com/response-writefile
Create page which will take id or image name as get parameter, then load image and writes it to response.
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "image/jpeg";
Bitmap test = new Bitmap("fileName.jpg");
test.Save(Response.OutputStream, ImageFormat.Jpeg);
精彩评论