ÔâÓöAsp.Net³¤ÎļþÃûÏÂÔصÄÎÊÌâºÍ½â¾ö°ì·¨
ÔÚAsp.NetÖÐдÁËÒ»¸ö¸½¼þÉÏ´«ºÍÏÂÔصijÌÐò£¬¸½¼þÉÏ´«µ½Êý¾Ý¿âÖУ¬È»ºó½«¸½¼þµÄGUID±£´æÆðÀ´£¬ÎÒÃÇ¿ÉÒÔ¸ù¾ÝGUIDÀ´ÕÒµ½Êý¾Ý¿âÖеĸ½¼þ£¬Ò»°ã¸½¼þÏÂÔصĴúÂëÊÇ£º
private void Download(string ID)
{
file = logic.GetAttachmentByID(new Guid(ID));
Response.AddHeader("Content-Type", file.Type);
Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode(file.FileName) + "\"");
Response.BinaryWrite(file.Data.ToArray());
Response.End();
}
ÕâÀï±È½ÏÖØÒªµÄ¾ÍÊÇResponse.AppendHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode(file.FileName) + "\"");ÕâÀïÐèÒª¶ÔÖÐÎÄÎļþÃû½øÐбàÂ룬ĬÈÏÊÇʹÓõÄUTF8±àÂë¡£µ«ÊDZàÂëºóÎļþÃû¾Í»á±äµÃºÜ³¤£¬±ÈÈçÎÒÏÖÔÚÓÐÒ»¸öÎļþ½Ð£º
ÕбêËͼìÑù»úÏîÄ¿¼ì²éµÇ¼Ç±í£¨Öնˣ©-¿Õ.XLS
ÎÒÃǽøÐÐÍøÂç×¥°ü£¬¿ÉÒÔ¿´µ½ÔÚÏÂÔØÎļþµÄʱºòµÄHTTPÏìÓ¦ÊÇ£º
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 44032
Content-Type: application/vnd.ms-excel
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 12.0.0.6219
X-AspNet-Version: 2.0.50727
Content-Disposition: attachment; filename="%e6%8b%9b%e6%a0%87%e9%80%81%e6%a3%80%e6%a0%b7%e6%9c%ba%e9%a1%b9%e7%9b%ae%e6%a3%80%e6%9f%a5%e7%99%bb%e8%ae%b0%e8%a1%a8(%e7%bb%88%e7%ab%af)-%e7%a9%ba.XLS"
Date: Wed, 25 Mar 2009 08:00:26 GMT
¿ÉÒԵõ½±àÂëºóÎļþÃû±ä³ÉÁË£º
%e6%8b%9b%e6%a0%87%e9%80%81%e6%a3%80%e6%a0%b7%e6%9c%ba%e9%a1%b9%e7%9b%ae%e6%a3%80%e6%9f%a5%e7%99%bb%e8%ae%b0%e8%a1%a8(%e7%bb%88%e7%ab%af)-%e7%a9%ba.XLS
ÕⶼÊÇÔÚHTTPÍ·ÀïÃæµÄ£¬ÓÉÓÚä¯ÀÀÆ÷»òÕßÆäËûÔÒò£¬¶ÔÓÚÕâô³¤µÄHTTPÍ·£¬ÏµÍ³»á¶Ô×Ö·û´®½øÐнØÖ¹£¬ÄÇô¾Í»áÔì³ÉÏÂÔصÄʱºòÎļþÃû²»È«»òÕ߸ɴà¾ÍÊÇÂÒÂëµÄÇé¿ö¡£ÎÒÊÔÁËһϣ¬Õâ¸öÎļþµÄÏÂÔØÔÚIE8ÀïÃæ
Ïà¹ØÎĵµ£º
public bool SaveExcel(GridView paramGridView)
{
if (paramGridView.Rows.Count == 0)
{
return false;
}
//´´½¨Excel¶ÔÏó
Microsoft.Office.Interop.Excel.Application myExcel = new Microsoft.Office.Interop.Excel.Appl ......
<%@ Page Language="C#" %>
<%@ import Namespace="System.Collections" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e) {
if(!Page.IsPostBack){
ArrayList data = new ArrayList();
data.Add(new Person("Tom",33,true));
data.Add(new Person("Jhon",39,false));
da ......
¹Ø±Õ´°Ìå
1.
this.btnClose.Attributes.Add("onclick", "window.close();return false;");
2.¹Ø±Õ±¾´°Ìå¼äÌøתµ½ÁíÒ»¸öÒ³Ãæ
this.HyperLink1.NavigateUrl = "javascript:onclick=window.opener.location.assign
......
//ƽ³£µ÷ÓÃjavascript·½·¨
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert'Weclome!!!');</script>");
±³¾°²»Îª°×É«µÄ·½·¨£º
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('Ìí¼Óʧ°Ü£¬ÇëÁªÏµ¼¼ÊõÔ±£¡') ......
ÏÖÔÚµÄÆóÒµ¼¶¿ª·¢ÏîÄ¿£¬ÌرðÊÇÍøÕ¾Ò»°ã¶¼»áÓõ½log¹¦ÄÜ£¬ÏëÏë´ó²¿·Ö»áÓÃEnterprise Logging Application Block µÄ¹¦ÄÜ »òÕß×Ô¼ºÐ´Ò»¸ö×é¼þ£¬¼Ç¼ϵͳÈÕ־ʼþ£¬¸üºÃµÄ¸ú×ÙÁ˽âϵͳÔËÐÐÇé¿ö, ÏÖÓÃASP.NET MVC µÄ¹ýÂËÊôÐÔʵÏÖlog¹¦ÄÜ£¡
ASP.NET MVCµÄfilter ÊÇÒ»¸öÊôÐÔ£¬¿ÉÒÔÓ¦Ó ......