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 *
* *
* Æ
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
Default.aspx CSÎļþ´úÂë
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _De ......
AtlasÊÇʲô£¿
atlas 2006-12-12 09:48 ÔĶÁ69 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
AtlasÊÇʲô£¿
ASP.NET”Atlas”ÊÇÒ»¸öеÄWeb¼¼Êõ¿ª·¢°ü£¬Ëü¼¯³ÉÁËÒ»Ì׷dz£´óµÄ¿Í»§¶Ë½Å±¾¿âʹµÃÓ빦ÄܷḻµÄ¡¢»ùÓÚ·þÎñÆ÷¿ª·¢Æ½Ì¨µÄASP.NET2.0½áºÏÔÚÒ»Æð£¬&rdq ......
Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspx ......
Æß¡¢ASP.NET Web ·þÎñÆ÷¿Ø¼þºÍ CSS Ñùʽ
Äú¿ÉÒÔͨ¹ýÉèÖø÷ÖÖÍâ¹ÛÊôÐÔ£¨Èç ForeColor¡¢BackColor¡¢Height ºÍ Width£©À´¿ØÖÆ ASP.NET ·þÎñÆ÷¿Ø¼þµÄÍâ¹Û¡£´ËÍ⣬²¿·Ö¿Ø¼þÖ§³Ö¹«¿ª¸½¼ÓÑùʽÏà¹ØÉèÖõÄÑùʽ¶ÔÏó¡£
˵Ã÷£º ASP.NET ÍøÒ³ÔÚÔËÐÐʱ¿ÉÒÔµ±×÷ HTML Ò³¡£ÄúÒò´Ë¿ÉÒÔÊ ......