All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
动态网页制作PHP之看实例学正则表达式_php资料_编程技术
Delphi以XPManifest组件显示界面
asp.net(c#)如何把字符串转换成数组_[Asp.Net教程]
如何在十天内学会php之第一天_php资料_编程技术
Asp.net页面输出成HTML页面_[Asp.Net教程]
在.NET中字符串替换的五种方法_.net资料_编程技术
C#基础学习,——,异步编程篇_.net资料_编程技术
Atlas快速入门之实战Atlas_.net资料_编程技术
C#教程:DLL动态链接库的DLL依赖项
网友原创-从N层到.NET详细剖析原理_.net资料_编程技术
Reading number is top 10 pictures
From China fortress sora aoi4
The real super beauty5
The girl of like self-time
西方气质的东方美女2
China telecom 114 spokesman MeiYanXu1
再发两张抽象画
yy365网站上的美女3
赵惟依写真2
The money of more than 100 countries and regions18
A man's favorite things7
Download software ranking
Boxer Classic video1
SQL2000 For 4IN1
Such love down(擒爱记)
White deer villiage
网页特效实例大全
linux初级教程
Unix video tutorial1
The hero
C#COM编程指南
Unix video tutorial7
delv published in(发表于) 2014/1/23 3:10:57 Edit(编辑)
ASP.NET中通过对话框方式下载文件_[Asp.Net教程]

ASP.NET中通过对话框方式下载文件_[Asp.Net教程]

ASP.NET中通过对话框方式下载文件_[Asp.Net教程]

ASP.NET中通过对话框方式下载文件


1 通过探出对话框提示文件下载或打开


2 通过自定义Header让特定的应用程序打开文件


使用的方法:Response.TransmitFile()


例程:


Response.ContentType = “image/jpeg”;
Response.AppendHeader(“Content-Disposition”,”attachment; filename=SailBig.jpg”);
Response.TransmitFile( Server.MapPath(“~/images/sailbig.jpg”) );


流传送所使用的方法:


Response.BinaryWrite()和Response.OutputStream()


例程:


Bitmap bmp = 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);


关于Content Type(MIME Type)的参考URL:


http://www.w3.org/TR/html4/types.html (概述)


http://www.iana.org/assignments/media-types/ (详细列表)


常见问题解决方案:


1、当从资源文件或者数据库BLOB字段载入图像出现错误


错误内容:A generic error occurred in GDI+


代码:


Bitmap bmp = this.GetGlobalResourceObject(“Resource”,”_BitMap”) as Bitmap;
Response.ContentType=”image/jpeg”;
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();


解决方法,再创建一个实例接收从资源文件或者数据库BLOB字段读入的图像内容。


解决方案代码:


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();

2、无法直接把PNG图像存入到输出流


原因:PNG是特殊的图片格式


解决方案代码:


Bitmap bmp = this.GetGlobalResourceObject( “Resource”, “_BitMap”) as Bitmap;
Bitmap temp = new Bitmap(bmp);
MemoryStream ms = new MemoryStream();
Response.ContentType=”image/png”;
temp.Save(ms, System.Drawing.Imaging, ImageFormat.Png);
Ms.WriteTo(Response.OutputStream);
bmp.Dispose();
temp.Dispose();
Response.End();


3、解决缓存问题


Response.ContentType=”image/png”;
Response.Buffer = false;
Response.Clear();
MemoryStream stream1 = new MemoryStream();
// DrawPie method return an Image
This.DrawPie(table1).Save(stream1,ImageFormat.Png);
Response.BinaryWrite(stream1.ToArray());
Base.OnPreInit(e);








添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.