易截截图软件、单文件、免安装、纯绿色、仅160KB

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 文件上传(Vb.net版)

在Asp.net中实现文件的上传功能,是非常简单的一件事情,只需要利用微软提供的FileUpload控件即可轻松实现。
LargeFileUpload.aspx代码如下
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LargeFileUpload.aspx.vb"
    Inherits="LargeFileUpload" %>
<!DOCTYPE html PUBLIC "-//W3C/ ......

ASP.NET的HTMLTable原样导出到Excel

 
文章出处:http://www.cnblogs.com/tomcat112906/articles/922639.html
 
ASP.NET的HTMLTable原样导出到Excel
js代码 : function PrintTableToExcelEx(objTab)
            {
        &nbs ......

Asp.net页面传值方法及实用技巧

一. 使用QueryString变量
    QueryString是一种非常简单也是使用比较多的一种传值方式,但是它将传递的值显示在浏览器的地址栏中,如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。
         Response.Redirect( "target.aspx?param1=hello& ......

影响ASP.Net应用性能的配置



影响ASP.Net应用性能的配置

1、删除不必要的HttpModule,每增加一个HttpModule,每个请求处理就多一点开销。
如:
<httpModules>
       & ......

asp.net用户ASPNET登录失败的问题

 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
  异常详细信息: System.Data.SqlClient.SqlException: 用户 'XXXASPNET' 登录失败。
  今天将网站迁移过来后,就发现这个问题.经过摸索,发现原因是我们登录数据库的角色对数据库的权限不够. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号