asp.net 用流的方式下载文件
//以下代码根据别人文章和自己整理
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace WebApplication1
{
public partial class DownfFile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// WriteFile下载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
string name ="DreamweaverCS3简体中文免激活绿色版.rar";
string path =Server.MapPath("DreamweaverCS3简体中文免激活绿色版.rar");
FileInfo fileinfo = new FileInfo(path);
long size = fileinfo.Length;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + name);
Response.AppendHeader("Content-Length", size.ToString());
Response.AppendHeader("Content-Transfer-Encoding", "binary");
Response.ContentEncoding = System.Text.Encoding.UTF8;//GetEncoding("gb2312");
Response.WriteFile(path,0,size);
Response.Flush();
Response.End();
}
/// <summary>
/// 使用OutputStream.Write分块下载文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button2_Click(object sender, EventArgs e)
{
string fileName = HttpContext.Current.Server.UrlEncode("DreamweaverCS3简体中文免激活绿色版.rar");
string filePath = HttpContext.Current.Server.MapPath("DreamweaverCS3简体中文免激活绿色版.rar");
//如果要写类的话用HttpResponse h
相关文档:
这是要实现的功能:
第一步:拖入GridView控件 并且完成查询所有数据的方法 通过this.GridView1.DataSource 获取集合数据 GridView1.DataBind() 绑定数据
第二步:实现全选功能
1. 页面代码:
代码
<asp:TemplateField HeaderText="全选">
&nbs ......
Asp.Net中有一套与用户相关联的属性设置,可以通过在WebConfig里配置来直接使用,他的作用为
存储和使用唯一与用户对应的信息
展现个人化版本的Web应用程序
用户的唯一身份标识在再次访问时识别用户
Asp.Net Profile提供的跟用户相关的类型都是强类型
首先生成数据库脚本,使用Visual Studio 2005 命令提示,输入 ......
模板化的数据绑定控件为我们在页面上显示数据提供了根本的灵活性。你可能还记得ASP.NET v1.x中的几个模板化控件(例如DataList和Repeater控件)。ASP.NET 2.0仍然支持这些控件,但在模板中绑定数据的语法已经被简化和改善了。本文将讨论在数据绑定控件模板中绑定数据的多种方法。
数据绑定表达式
ASP.NET 2.0改善了模板中 ......
认识ASP.NET配置文件Web.config
一、认识Web.config文件
Web.config文件是一个XML文本文件,它用来储存 ASP.NET Web 应用程序的配置信息(如最常用的设置ASP.NET Web 应用程序的身份验证方式),它可以出现在应用程序的每一个目录中。当你通过VB.NET新建一个Web应用程序后,默认情况下会在根目录自动创建一个默认的 ......