ASP.NET 2.0 ÎļþÏÂÔØ£¨Ö§³Ö´óÎļþ¡¢·ÀµÁÁ´£©
1.ÎļþÏÂÔØ
HTTP ÎļþÏÂÔØÖ÷ÒªÓÐÁ½ÖÖ·½Ê½£º
URL·½Ê½Ö±½ÓÏÂÔØ£¬ÓŵãÊÇ£ºÕ¼Ó÷þÎñÆ÷×ÊÔ´ÉÙ£¬Ëٶȿ죻ȱµãÊÇ£º ²»ÄÜ׼ȷ¼ÆÁ¿ÏÂÔØ´ÎÊý£¬ÎÞ·¨·ÀÖ¹µÁÁ´£¬±£´æÔÚÊý¾Ý¿âÖеÄÎļþÎÞ·¨ÏÂÔØ£¬³£¼û¸ñʽµÄÎļþÈç.html Ö±½ÓÔÚä¯ÀÀÆ÷Öдò¿ª£¬²»ÄÜÖ±½ÓÏÂÔØ¡£
¶þ½øÖÆÊý¾ÝÁ÷Êä³ö·½Ê½£¬ÓŵãÊÇ£º×¼È·¼ÆÁ¿ÏÂÔØ´ÎÊý¡¢ÄÜ·ÀµÁÁ´¡¢ËùÓÐÎļþ¸ñʽ¶¼ÄÜÖ±½ÓÏÂÔضø²»ÊÇ´ò¿ª¡¢±£´æÔÚÊý¾Ý¿âÖеȷÇÎļþÊý¾ÝÄÜÒÔÎļþ·½Ê½ÏÂÔصȣ»È±µãÊÇÕ¼Ó÷þÎñÆ÷×ÊÔ´¶à¡£
´óÎļþÏÂÔØÔÀíÊÇ°ÑÎļþÇгÉС¶ÎÊý¾ÝÁ÷ÏÂÔØ£¬Î¢Èímsdn¸ø³öÁË´óÎļþÏÂÔصÄʾÀý£¬µ«´æÔÚÖÐÎÄÎļþÃûÂÒÂëÎÊÌ⣬ÉԼӸĶ¯¼´¿É¡£´úÂëΪ£º
protected void ResponseFile(string path)
{
System.IO.Stream iStream = null;
byte[] buffer = new Byte[10000];
int length;
long dataToRead;
string filename = System.IO.Path.GetFileName(path);
try
{
iStream= new System.IO.FileStream(path, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead= iStream.Length;
Response.ContentType= "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
while (dataToRead > 0)
{
if (Response.IsClientConnected)
{
length= iStream.Read(buffer, 0, 10000);
Response.OutputStream.Write(buffer,0, length);
Response.Flush();
buffer = new Byte[10000];
dataToRead= dataToRead - length;
}
else
{
dataToRead= -1;
}
}
}
catch (Exception ex)
{
Response.Write("ÎļþÏÂÔØʱ³öÏÖ´íÎó!");
}
finally
{
if (iStream != null)
{
iStream.Close();
}
}
}
2.·ÀÖ¹µÁÁ´
protected void Page_Load(object sender, EventArgs e)
{
/*--------------------------------------------------------------*\
* ´óÎļþÏÂÔØ£¬·ÀµÁÁ´ *
* *
* tda7264@163.com *
* *
* Æ
Ïà¹ØÎĵµ£º
using System;
using System.Collections.Specialized;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebC ......
ËÄ¡¢ÈçºÎ£ºÖ¸¶¨ÊÇ·ñ½« ASP.NET Web ·þÎñÆ÷¿Ø¼þ·¢Ë͵½·þÎñÆ÷
ĬÈÏÇé¿öÏ£¬Óû§ÔÚ ASP.NET ÍøÒ³ÖÐÖ¸¶¨µÄÐÅÏ¢ºÍÑ¡Ôñ²»»áÁ¢¼´·¢Ë͵½·þÎñÆ÷¡£¶øÊÇÖ»ÔÚ·¢ËÍÕû¸öҳʱ·¢ËÍÖµ£¬²¢ÇÒͨ³£ÊÇÔÚÏìÓ¦°´Å¥µ¥»÷ʱ·¢Éú¡£µ«ÊÇ£¬Äú¿ÉÄܻᷢÏÖËüÔÚÏò·þÎñÆ÷Á¢¼´·¢ËÍÓû§¸ü¸Äʱ·Ç³£ÓÐÓá£
Á¢¼´½«¿Ø¼þÖµ·¢Ë͵½·þÎ ......
Æß¡¢ASP.NET Web ·þÎñÆ÷¿Ø¼þºÍ CSS Ñùʽ
Äú¿ÉÒÔͨ¹ýÉèÖø÷ÖÖÍâ¹ÛÊôÐÔ£¨Èç ForeColor¡¢BackColor¡¢Height ºÍ Width£©À´¿ØÖÆ ASP.NET ·þÎñÆ÷¿Ø¼þµÄÍâ¹Û¡£´ËÍ⣬²¿·Ö¿Ø¼þÖ§³Ö¹«¿ª¸½¼ÓÑùʽÏà¹ØÉèÖõÄÑùʽ¶ÔÏó¡£
˵Ã÷£º ASP.NET ÍøÒ³ÔÚÔËÐÐʱ¿ÉÒÔµ±×÷ HTML Ò³¡£ÄúÒò´Ë¿ÉÒÔÊ ......
¾Å¡¢ÒÔ±à³Ì·½Ê½Ìí¼Ó ASP.NET ¿Ø¼þ
ÓÐʱ£¬ÔÚÔËÐÐʱ´´½¨¿Ø¼þ±ÈÔÚÉè¼Æʱ´´½¨¿Ø¼þ¸ü¿ÉÐС£ÀýÈ磬¼Ù¶¨ÓÐÒ»¸öËÑË÷½á¹ûÒ³£¬ÄúÒªÔÚÆäÖн«ÒÔ±íµÄÐÎʽÏÔʾ½á¹û¡£ÓÉÓÚ²»ÖªµÀÒª·µ»Ø¶àÉÙÏÒò´ËÄúÐèҪÿ¸ö·µ»ØµÄÏ̬Éú³ÉÒ»¸ö±íÐС£
˵Ã÷£º ÏÖÓпؼþͨ³£¿ÉÒÔÌṩ´Ó¶¯ ......
ÔÚASP.NET ÖÐʵÏÖµ¥µãµÇ¼
³ö×Ô£º¡¾ÃÏÏÜ»áÖ®¾«²ÊÊÀ½ç¡¿ ·¢²¼ÈÕÆÚ£º2005Äê1ÔÂ27ÈÕ 8µã48·Ö0Ãë
ÓÉÓÚijЩÔÒò£¬ÔÚÎÒÃǵÄÓ¦ÓÃÖлáÓöµ½Ò»¸öÓû§Ö»ÄÜÔÚÒ»¸öµØ·½µÇ¼µÄÇé¿ö£¬Ò²¾ÍÊÇÎÒÃÇͨ³£Ëù˵µÄµ¥µãµÇ¼¡£ÔÚASP.NETÖÐʵÏÖµ¥µãµÇ¼ÆäʵºÜ¼òµ¥£¬ÏÂÃæ¾Í°ÑÖ÷ÒªµÄ·½·¨ºÍÈ«²¿´úÂë½øÐзÖÎö¡£
ʵÏÖ˼·
ÀûÓÃCacheµÄ¹¦ÄÜ ......