ASP.NET文件下载函数
在你的Page_Load中添加这样的代码:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "目的文件名称", @"源文件路径", 1024000);
if (!success)
Response.Write("下载文件出错!");
Page.Response.End();
文件下载函数代码为:
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
相关文档:
1、使用值类型的ToString方法
在连接字符串时,经常使用"+"号直接将数字添加到字符串中。这种方法虽然简单,也可以得到正确结果,但是由于涉及到不同的数据类型,数字需要通过装箱操作转化为引用类型才可以添加到字符串中。但是装箱操作对性能影响较大,因为在进行这类处理时,将在托管堆中分配一个新的对象,原有的值 ......
解决办法:app_code/ 存放一个类 用来截获HTTP
1.代码如下
using System;
using System.IO;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
/// <summary>
/// Removes whitespace from the webpage.
/// </summary>
public class ViewstateModule : IHttpModule
{
......
http://www.cnblogs.com/JimmyZhang/archive/2007/11/25/971878.html
引言
Http 请求处理流程 和 Http Handler 介绍 这两篇文章里,我们首先了解了Http请求在服务器端的处理流程,随后我们知道Http请求最终会由实现了IHttpHandler接口的类进行处理(应该记得Page类实现了IHttpHandler)。从 Http 请求处理流程 一文的最后的 ......
GridView使用详解
01 GridView无代码分页排序
02 GridView选中,编辑,取消,删除
03 GridView正反双向排序
04 GridView和下拉菜单DropDownList结合
05 GridView和CheckBox结合
06 鼠标移到GridView某一行时改变该行的背景色方法一
07 鼠标移到GridView某一行时改变该行的背景 ......
直接获得页面参数:
if(!IsPostBack) { //判断是否是第一次加载窗体
}
if(Page.PreviousPage!=null){ // 判断上一页面的按钮是� ......