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");//·¾¶
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Lengt
Ïà¹ØÎĵµ£º
1¡¢Ìí¼ÓWeb.config£¬ < system.web>< /system.web>ÖÐÌí¼Ó< customErrors mode="On"
defaultRedirect="ApplicationErroy.aspx" >< /customErrors>½Úµã£¬
2¡¢Ìí¼ÓGlobal.asaxÎļþ£¬ÕÒµ½Application_Errorʼþ£¬¼ÓÈëÒÔÏ´úÂ룺
//ÕâÊÇÌí¼ÓÁËÒ»¸öÈ«¾ÖÓ¦ÓÃ³Ì ......
Global.asax Îļþ£¬ÓÐʱºò½Ð×ö asp.net Ó¦ÓóÌÐòÎļþ£¬ÌṩÁËÒ»ÖÖÔÚÒ»¸öÖÐÐÄλÖÃÏìÓ¦Ó¦ÓóÌÐò¼¶»òÄ£¿é¼¶Ê¼þµÄ·½·¨¡£Äã¿ÉÒÔʹÓÃÕâ¸öÎļþʵÏÖÓ¦ÓóÌÐò°²È«ÐÔÒÔ¼°ÆäËüһЩÈÎÎñ¡£ÏÂÃæÈÃÎÒÃÇÏêϸ¿´Ò»ÏÂÈçºÎÔÚÓ¦ÓóÌÐò¿ª·¢¹¤×÷ÖÐʹÓÃÕâ¸öÎļþ¡£
¸ÅÊö
Global.asax λÓÚÓ¦ÓóÌÐò¸ùĿ¼Ï¡£ËäÈ» Visual Studio .NET »á×Ô¶¯²åÈëÕ⸠......
SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
SqlCommand cmdAdd = new SqlCommand( "Community_Disc ......
Ò»¡¢ÔÀí£º
ҪʵÏÖ½ø¶ÈÌõµÄʵʱ·´Ó³£¬ºËÐĵļ¼Êõ¾ÍÊǶÔÉÏ´«µÄÊý¾Ý½øÐГ·Ö¿é”¶ÁÈ¡£¬ÔÚ¶Áȡÿ¿éÊý¾Ýʱ¼Ç¼µ±Ç°ÒÑÉÏ´«µÄ¿éÊý£¬¸ù¾Ý
·Ö¿éµÄ´óС£¬¼´¿ÉÖªµÀÒÑÉÏ´«µÄ´óС£¬¸ù¾Ý×Ü´óС£¬¼´¿ÉÖªµÀµ±Ç°ÉÏ´«µÄ½ø¶È¡£¾ßÌåµÄ¼¼Êõ»¹ÊÇÀûÓÃÒþº¬µÄHttpWorkerRequest
£¬ÓÃËüµÄGetPreloadedEn ......