62,046
社区成员
发帖
与我相关
我的任务
分享
string path = context.Request.QueryString["path"];
string fileName = context.Request.QueryString["filename"];
context.Response.ContentType = "application/octet-stream";
// 文件重命名
context.Response.AppendHeader("Content-Disposition", string.Format("attachment;filename={0};charset=GB2312",
System.Web.HttpUtility.UrlEncode(string.IsNullOrEmpty(fileName) ? System.IO.Path.GetFileName(path) : fileName, System.Text.Encoding.UTF8)));
string physicalPath = context.Server.MapPath("~/" + path);
if (!System.IO.File.Exists(physicalPath))
{
throw new System.IO.FileNotFoundException();
}
context.Response.WriteFile(physicalPath);
<authentication mode="Forms">
<forms loginUrl="Default.aspx" name=".ASPXAUTH" protection="All">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>