ASP.NETÎļþÏÂÔØº¯ÊýʹÓÃ
ASP.NETÎļþÏÂÔØº¯ÊýʹÓÃÊÇʲôÇé¿öÄØ£¿ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success) Response.Write("ÏÂÔØÎļþ³ö´í£¡"); Page.Response.End();
ASP.NETÎļþÏÂÔØº¯Êý´úÂëΪ:
public static bool ResponseFile(HttpRequest _Request,HttpResponse _Response,string _fileName,string _fullPath, long _speed) {
try
{
FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader br = new BinaryReader(myFile);
try
{
_Response.AddHeader("Accept-Ranges", "bytes"
);
_Response.Buffer = false;
long fileLength = myFile.Length;
long startBytes = 0; double pack = 10240;
//10K bytes
//int sleep = 200;
//ÿÃë5´Î ¼´5*10K bytesÿÃë int sleep = (int)Math.Floor(1000 * pack / _speed) + 1;
if (_Request.Headers["Range"] != null)
{
_Response.StatusCode = 206;
string[] range = _Request.Headers["Range"].Split(new char[] {'=', '-'});
startBytes = Convert.ToInt64(range[1]);
}
_Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
if (startBytes != 0) {
//Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength-1, fileLength));
}
_Response.AddHeader("Connection", "Keep-Alive");
_Response.ContentType = "application/octet-stream";
_Response.AddHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlEncode(_fileName,System.Text.Encoding.UTF8) ); br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
int maxCount = (int) Math.Floor((fileLength - startBytes) / pack) + 1;
for (int i = 0; i < maxCount; i++) { if (_Response.IsClientConnected) { _Response.BinaryWrite(br.ReadBytes(int.Parse(pack.ToString()))); Thread.Sleep(sleep);
} else { i=maxCount;
}
} }
catch
{
return false;
}
finally
{
br.Close();
myFile.Close();
}
}
catch
{
return false;
}
return true;
}
ÕâÑù¾ÍʵÏÖÁË
Ïà¹ØÎĵµ£º
Ô´ÌùµØÖ·£ºhttp://www.cnblogs.com/yanyangtian/archive/2009/05/07/1451705.html
ǰÑÔ£ºÒì³£µÄ´¦ÀíÔÚÏîÄ¿¿ª·¢ÖÐÊǺÜÓбØÒªµÄ£¬Òì³£µÄ´¦Àí²»½ö½öÖ»ÊÇtry..catch..finally¾ÍÍêÊÂÁ˵ġ£Òì³£´¦Àí¾ø¶Ô¿ÉÒԳƿª·¢ÖеÄÖØÒª×é³É²¿·Ö¡£±ØÐëÕýÈ·µÄÃæ¶ÔÒì³ ......
1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º
´«ËͲÎÊý£º
response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</script>")
½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1.Attribut ......
asp.net±ÏÒµÉè¼Æ¾ÍÊÇÓÃC#ÓïÑÔ¿ª·¢µÄWEBµÄ±ÏÒµÉè¼Æ£¬ÏÖÔںöà´óѧ¶¼Ñ¡ÔñÓÃasp.netÀ´×ö±ÏÒµÉè¼Æ£¬±¾Õ¾¿ªÊ¼×ö±ÏÒµÉè¼Æ¾ÍÑ¡ÔñÁËasp.net¿ª·¢±ÏÒµÉè¼Æ±ðµÄÉè¼Æ²»×ö¡£
¶¨×öasp.net±ÏÒµÂÛÎÄרÏߣº
±à³ÌÁªÃËÕ¾³¤
QQ£º153933864 êdzƣºÐÇÆÚ°Ë
ÁõÏÈÉú£ºÊÖ»ú£º13733310210
ÎÒÃǵÄasp.net±ÏÒµÉè¼Æ³ÉÆ·Ö÷Òª²¿·ÖÔÚÏÂÃæÁгö£º
±¾Õ¾ÒÔ¶ ......
ת£ºhttp://www.cnblogs.com/kumaws/articles/web_architecture.html
Ïà¶ÔÓÚ²»Í¬µÄÐèÇó£¬ÍøÕ¾µÄ´óС£¬¿ª·¢¸´ÔÓ¶È£¬³É±¾£¬ÍøÕ¾µÄ¼Ü¹¹Ò²·ÖÐí¶àÖÖ¡£
´ó¶àÊýСÐÍÍøÕ¾£¬ÐèÇó½ÏΪ¼òµ¥£¬°²È«ÐÔÒªÇ󲻸ߣ¬¿ª·¢Ê±¼ä¶Ì¡£Ò»°ãÕâÑùµÄÍøÕ¾£¬»¹»áÓÐÒ»¸öÓëÊý¾Ý¿âÖ®¼äµÄ½»»¥¡£ÓÃAsp.NetÖÐÌṩµÄ¿Ø¼þ£¬ÍêÈ«¿ÉÒÔÂú×㿪·¢µÄÒªÇó¡£Ò»° ......