ASP.NET ÎļþÏÂÔØ
ÏÂÔØÒ³Ãæ£º
<a href="download.ashx?url=<%=Server.UrlEncode("˵Ã÷.txt")%>">ÏÂÔØ</a>
------------------------------------------------------------------------------
download.ashx
<%@ WebHandler Language="C#" Class="download" %>
using System;
using System.Web;
public class download : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string url = HttpContext.Current.Server.UrlDecode(context.Request.QueryString["url"]);
downloadfile(url);
}
public bool IsReusable {
get {
return false;
}
}
public void downloadfile(string s_fileName)
{
HttpContext.Current.Response.ContentType = "application/ms-download";
string s_path = HttpContext.Current.Server.MapPath("~/") + s_fileName;
System.IO.FileInfo file = new System.IO.FileInfo(s_path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream");
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.WriteFile(file.FullName);
Ïà¹ØÎĵµ£º
ÔÚAsp.netÖÐʵÏÖÎļþµÄÉÏ´«¹¦ÄÜ£¬ÊǷdz£¼òµ¥µÄÒ»¼þÊÂÇ飬ֻÐèÒªÀûÓÃ΢ÈíÌṩµÄFileUpload¿Ø¼þ¼´¿ÉÇáËÉʵÏÖ¡£
LargeFileUpload.aspx´úÂëÈçÏÂ
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LargeFileUpload.aspx.vb"
Inherits="LargeFileUpload" %>
<!DOCTYPE html PUBLIC "-//W3C/ ......
ÎÄÕ³ö´¦£ºhttp://hi.baidu.com/richiezheng/blog/item/8bb94b8692315b3867096efa.html
ÀûÓÃASP.NET¼¼Êõ¶¯Ì¬Éú³ÉHTMLÒ³Ãæ
˼·
¡¡¡¡1. ÀûÓÃÈçDw-MxÕâÑùµÄ¹¤¾ßÉú³Éhtml¸ñʽµÄÄ£°å£¬ÔÚÐèÒªÌí¼Ó¸ñʽµÄµØ·½¼ÓÈëÌØÊâ±ê¼Ç(Èç$htmlformat$),¶¯Ì¬Éú³ÉÎļþʱÀûÓôúÂë¶ÁÈ¡´ËÄ£°å£¬È»ºó»ñµÃǰ̨ÊäÈëµÄÄÚÈÝ£¬Ìí¼Óµ½´ËÄ£°åµÄ±ê¼ÇλÖÃÖ ......
µÚÒ»ÖÖ·½·¨ÊǶÔÒ»¸öaspxÒ³ÃæÉú³ÉhtmlÎļþ£¬ÏȶԷþÎñÆ÷·¢ËÍÇëÇóaspxÒ³Ãæ£¬È¡·þÎñÆ÷·µ»ØµÄhtmlÁ÷£¬Ð´µ½Ò»¸öhtmlÎļþÀaspxÒ³ÃæÏÔʾµÄÊÇʲô£¬Éú³ÉµÄhtmlÒ³Ãæ¾ÍÊÇʲô
£±¡¢asp·½·¨£º
sub createHTML
dim xmlhttp,strhtml,objAdoStream,i,myurl
set xmlhttp=server.CreateObject("Microsoft.XMLHTTP")
&nb ......
ÅäÖÃÎļþ¿ÉÓÃÀ´´æ·ÅһЩ¶à´ÎÓõ½µÄ³£Á¿Êý¾Ý£¬ÈçÁ¬½Ó´®£º
<appSettings>
<add key="connStr1" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
<add key="connStr2" value="App_Data\test.mdb"/>
</appSettings>
Õâ¸öÅäÖÃÊý¾Ý¿âÁ¬½Ó´®
ʹÓÃʾÀý£º
public class DBCo ......