ASP.NETʵÏÖÎļþÏÂÔØ
//TransmitFileʵÏÖÏÂÔØ
protected void Button1_Click(object sender, EventArgs e)
{
/*
΢ÈíΪResponse¶ÔÏóÌṩÁËÒ»¸öÐµķ½·¨TransmitFileÀ´½â¾öʹÓÃResponse.BinaryWrite
ÏÂÔØ³¬¹ý400mbµÄÎļþʱµ¼ÖÂAspnet_wp.exe½ø³Ì»ØÊÕ¶øÎÞ·¨³É¹¦ÏÂÔØµÄÎÊÌâ¡£
´úÂëÈçÏ£º
*/
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment;filename=z.zip");
string filename = Server.MapPath("DownLoad/z.zip");
Response.TransmitFile(filename);
}
//WriteFileʵÏÖÏÂÔØ
protected void Button2_Click(object sender, EventArgs e)
{
/*
using System.IO;
*/
string fileName = "asd.txt";//¿Í»§¶Ë±£´æµÄÎļþÃû
string filePath = Server.MapPath("DownLoad/aaa.txt");//·¾¶
Ïà¹ØÎĵµ£º
Ö±½Ó»ñµÃÒ³Ãæ²ÎÊý£º
if(!IsPostBack) { //ÅжÏÊÇ·ñÊǵÚÒ»´Î¼ÓÔØ´°Ìå
}
if(Page.PreviousPage!=null){ // ÅжÏÉÏÒ»Ò³ÃæµÄ°´Å¥ÊÇ· ......
ÔÀ´ÓÃjQueryµÄajax·½Ê½µ÷ÓÃasp.netÒ³Ãæ»ù±¾¶¼Êǵ÷Óõ¥¸öÒ³Ãæ£¬Óɵ÷ÓÃÒ³ÃæResponseÄÚÈÝ£¬¶øÏÖÔÚ²ÉÓÃasp.net ajaxºó£¬ÎÒÃÇÔò¿ÉÒÔ¸üÍêÃÀµÄʹÓÃjQueryºÍasp.net½áºÏÁË£¬´úÂëÈçÏ£º
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Scripts>
<asp:ScriptReference Path="http ......
Asp.Net³ÌÐòµÄ¸ß¼¶¹¦ÄÜ£¬Óкܶ඼ÊÇ»ùÓÚIHttpHandler½Ó¿ÚÀ´ÊµÏֵģ¬ÔÚWinwods Server 2003 Ï£¬ÅäÖÃIIS6µÄ Web·þÎñÀ©Õ¹·Ç³£¼òµ¥¡£×î½üÓÃWin7+IIS7.5µÄÈËÔ½À´Ô½¶à£¬ÔÚÕâ¸ö»·¾³ÏÂÅäÖÃAsp.NetµÄWeb·þÎñÀ©Õ¹¾ÍÓÐЩÂé·³¡£ÒÔÏÂÄÚÈÝ£¬¾ÍÊÇÔÚWin7ºÍIIS7.5»·¾³ÏÂÅäÖùý³Ì¡£
& ......
ASP.NETÏÂÔØ——word,txt,ͼƬ·½·¨
¡¡¡¡±¾ÎÄÖ÷Òª½éÉÜASP.NETÏÂÔØÖîÈçword,txt,ͼƬµÈµÄ·½·¨¡£
¡¡
¡¡ try
¡¡¡¡{
¡¡¡¡FullFileName = Server.MapPath(FileName); //FileName--ÒªÏÂÔØµÄÎļþÃû
¡¡¡¡FileInfo DownloadFile= new FileInfo(FullFileName);
¡¡¡¡if(Down ......
Ê×ÏÈÌí¼ÓÃüÃû¿Õ¼ä
using System.Data.OleDb;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
strfile = Request.QueryString["filename"];//´ÓÆäËûÒ³Ãæ´«¹ýÀ´µÄÎļþ·¾¶
Excel(strfile);
}
}
private v ......