1 to download or open the file by probing the dialog box
2 allow a specific application to open a file through a custom header
Method of Use: Response.TransmitFile ()
Routines:
以下是引用片段:
Response.ContentType=“image/jpeg”;
Response.AppendHeader(“Content-Disposition”,”attachment;filename=SailBig.jpg”);
Response.TransmitFile(Server.MapPath(“~/images/sailbig.jpg”));
流传送所使用的方法:Response.BinaryWrite()和Response.OutputStream()
Routines:
以下是引用片段:
Bitmapbmp=wwWebUtils.CornerImage(backcolor,color,c,Radius,Height,Width);
Response.ContentType=“image/jpeg”;
Response.AppendHeader(“Content-Disposition”,”attenment;filename=LeftCorner.jpg”);
bmp.Save(Response.OutputStream,ImageFormat.Jpeg);
Reference URL for the content Type (MIME type):
Http://www.w3.org/TR/html4/types.html (Overview)
http://www.iana.org/assignments/media-types/(Detailed list)
FAQ Solution:
1. Error occurred loading image from resource file or database blob field
Error content: A generic error occurred in GDI +
Code:
以下是引用片段:
Bitmapbmp=this.GetGlobalResourceObject(“Resource”,”_BitMap”)asBitmap;
Response.ContentType=”image/jpeg”;
bmp.Save(Response.OutputStream,ImageFormat.Jpeg);
Response.End();
Workaround, and then create an instance to receive the image content that is read from the resource file or from the Database Blob field.
Solution Code:
以下是引用片段:
Bitmap bmp = this.GetGlobalResourceObject(“Resource”, ”_BitMap”) as Bitmap;
Bitmap temp = new Bitmap(bmp);
Response.ContentType = “image/jpeg”;
Temp.Save(Response.OutputStream, ImageFormat.Jpeg);
bmp.Dispose();
temp.Dispose();
Response.End();