虚拟主机域名注册-常见问题虚拟主机问题 → 虚拟主机问题


[原创][22SEO技术网]ASP.NET下载是页面(xxx.aspx)问题-oracle
作者:系统管理员

以下内容仅代表本人观点:http://www.joceancloud.com
http://blog.ipart.cn/blog/blog_new_diary_viewmore.php?u=27819474&d=3免备案空间 

解决方法:将下载页面中及下面的标注的红体字去掉就OK
<%@ Page Language="C#" ValidateRequest="false" CodeFile="DownQuestion.aspx.cs" Inherits="teacher_DownQuestion" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>下载发布作业</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs代码
#region 替换字符串
public static string repString(object obj)
{
return StringHandler.repString(obj);
}
#endregion

protected void Page_Load(object sender, EventArgs e)
{
//获取文件路径
string path = repString(Request.QueryString["url"].ToString());
//初始化 FileInfo 类的实例,它作为文件路径的包装
FileInfo fi = new FileInfo( path);
//判断文件是否存在
if (fi.Exists)
{
//将文件保存到本机上
//将文件保存到本机上
Response.Clear();
Context.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Filter.Close();
Response.End();
}
else
{
Response.Write("<script>alert('文件有误,请重试!');window.history.back();</script>");
}
}
http://www.joceancloud.comhttp://my.pclady.com.cn/d/3135819.html
原文转自杰森云数码:http://www.joceancloud.com
免费虚拟主机22US数码:http://www.22us.net
便宜空间:http://www.22new.net

 



来源:
阅读:2043
日期:2013-02-28

【 双击滚屏 】 【 推荐朋友 】 【 收藏 】 【 打印 】 【 关闭 】 【 字体: 】 
上一篇:关于win2008+iis7无组件上传写入文件失败ADODB.Stream 错误 800a0
下一篇:[原创][22SEO技术网]ASP.NET web.config添加Oracle连接字符串-便宜空间
  >> 相关文章