Method 1: display the source Image
Using System;
Namespace DtCms. Web. Tools
{
Public partial class img: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
String gurl = "/UpLoadFiles/20110117/2011011719440778 .jpg ";
Response. ContentType = "image/jpg ";
Response. Clear ();
Response. WriteFile (gurl );
}
}
}
Method 2: display the source image in binary format
Using System;
Using System. IO;
Namespace DtCms. Web. Tools
{
Public partial class httpimg: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
String filePath = "image path ";
Response. ContentType = "image/jpg ";
FileStream imageStr = new FileStream (filePath, FileMode. Open );
Byte [] imageData = new byte [imageStr. Length];
ImageStr. Read (imageData, 0, (int) imageStr. Length );
Response. OutputStream. Write (imageData, 0, (int) imageStr. Length );
}
}
}