ASP.NETʵÏÖ´Ó·þÎñÆ÷ÏÂÔØÎļþ(¼Ç¼)
¼ÙÉèÔÚ·þÎñÆ÷µÄ¸ùĿ¼ÏÂÓиöÃûΪDownloadµÄÎļþ¼Ð,Õâ¸öÎļþ¼Ð´æ·ÅһЩÌṩ¸øÒýÓóÌÐòÏÂÔØµÄÎļþ..
public void DownloadFile(string path, string name)
{
try
{
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// Ìí¼ÓÍ·ÐÅÏ¢£¬Îª"ÎļþÏÂÔØ/Áí´æÎª"¶Ô»°¿òÖ¸¶¨Ä¬ÈÏÎļþÃû
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
// Ìí¼ÓÍ·ÐÅÏ¢£¬Ö¸¶¨Îļþ´óС£¬ÈÃä¯ÀÀÆ÷Äܹ»ÏÔʾÏÂÔØ½ø¶È
Response.AddHeader("Content-Length", file.Length.ToString());
// Ö¸¶¨·µ»ØµÄÊÇÒ»¸ö²»Äܱ»¿Í»§¶Ë¶ÁÈ¡µÄÁ÷£¬±ØÐë±»ÏÂÔØ
Response.ContentType = "application/ms-excel";
// °ÑÎļþÁ÷·¢Ë͵½¿Í»§¶Ë
Response.WriteFile(file.FullName);
// Í£Ö¹Ò³ÃæµÄÖ´ÐÐ
//Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔǰµÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕß¶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
ASP.NetÖÐ×îΪͷʹµÄ¿ÉÄܾÍÊÇ´òÓ¡ÉèÖÃÁË¡£
ΪÁËÕâ¸öÎÊÌ⣬ÎÒ¶¼Òª°¾°×Í·ÁË¡£ÍøÉÏÒ²ÕÒÁ˺ܶà´úÂ룬µ«ÊÇ×ÜÊÇ»á´æÔÚһЩÎÊÌâ¡£¸ù¾ÝÎÒ×Ô¼ºµÄʵ¼ÊÊÔÑé·¢ÏÖ²»ÄÜÓã¬ÎªÕÒ²»µ½¶ÔÏóÖ®ÀàµÄ´íÎóÌáʾ¡£
ÕâÀï¸ø³öÁ½ÖÖʵ¼Ê¿ÉÓõķ½·¨£º
Ò»¡£Í¨¹ý×¢²á±íÐÞ¸ÄIE´òÓ¡ÉèÖÃ
<HTML>
<HEAD>
< ......
Ê®Ììѧ»áASP.net֮ʵսϵÁУ¨C#ºÍVb.netË«°æ±¾£©
µÚÒ»Ìì
ÎÒÈÏΪASP.NET±ÈASPÄѺܶ࣬ϣÍû´ó¼Ò×öºÃ×¼±¸¡£ÄÑÄÑÔÚʵÏÖͬһ¸öЧ¹ûÓкܶ෽·¨£¬´ó¼Ò»òÐí»áÒÉ»ó¡£Ê®Ììѧ»áϵÁн̳̻áÇåÎúµÄд³ö¸÷ÖÖ·½·¨£¬Èôó¼ÒÄÜÉÙÒ»µã¿²¿À¡£ÔÚASPÀïÃæ£¬´ó¼Ò¼¸ºõ¶¼ÊÇʹÓÃVB£¬Êý¾Ý¿âÂҲÎÞ·ÇÊÇSQLºÍACCESS¡£ÔÚASP.NETÀïÃæ£¬Êý¾Ý¿â»¹ÊÇÕ ......
¸ÅÄÆäʵ˼··Ç³£¼òµ¥£¬¾ÍÏñ»»Ò»Ñù£¬ÄãÄÔÖеıýͼÏëɶÑù×ӵģ¬¾Í°ÑËüÔÚÍøÒ³ÀﻳöÀ´¶øÒÑ¡£ÏàÐÅ´ó¼ÒСʱºò¶¼»¹ý»£¬²»Í¬µÄÊÇ£¬Ð¡Ê±ºò£¬ÔÚÖ½ÉÏ»£¬ÏÖÔÚÔÚÍøÒ³ÉÏ»¡£
ÕâÊÇÎÒÄÔ×ÓÀï±ýͼµÄÑù×Ó£º<¼¤¹â´«Õæ»ú>
C#ºǫ́ʾÀý´úÂ룺<¼¤¹âÒ»Ìå»ú>
using System;
using System.Data;
using System.Configur ......