文件下载后树不能用了~~~~~~```

stringbuilder 2006-02-27 10:58:19
在框架的情况下,下载一个文件,弹出对话框后点保存,下载了后左边的树就没有反应了!


我用了Iframe处理,在弹出对话框后点取消,然后再点下载,会出现线程错误!高手来解!
...全文
83 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
stringbuilder 2006-02-28
  • 打赏
  • 举报
回复
在download.aspx里面的代码:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
ApplyLicense(Me.Request.QueryString("valuedata"))
End Sub


Public Shared Function ApplyLicense(ByVal aClientName As String) As Boolean
Try
aClientName = aClientName.Trim

Dim ls_applyfile As String = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath) + "\" + aClientName + ".lic"



Dim fi As New FileInfo(ls_applyfile)


HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.Buffer = False

HttpContext.Current.Response.AddHeader("Content-DisPosition", "attachment;filename=" + HttpUtility.UrlEncode(fi.Name).ToString())
HttpContext.Current.Response.AddHeader("Content-Length", fi.Length.ToString())
HttpContext.Current.Response.ContentType = "application/octet-stream"
HttpContext.Current.Response.WriteFile(fi.FullName)

HttpContext.Current.Response.Flush()

If File.GetAttributes(ls_applyfile).ReadOnly Then File.SetAttributes(ls_applyfile, FileAttributes.Normal)
File.Delete(ls_applyfile)
HttpContext.Current.Response.End()


Return True
Catch ex As Exception
HttpContext.Current.Response.Write("<script language='javascript'>alert('" + "下载错!" + ex.ToString.Replace("\r\n", "\\r\\n") + "');</script>")
Return False
End Try
End Function


你们运行下就知道了,点download,然后点保存,然后点取消,再点download,哈哈,出问题了!
stringbuilder 2006-02-28
  • 打赏
  • 举报
回复
第二个页面download.aspx

<HTML>
<HEAD>
<title>downLoad</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"></FONT>
</form>
</body>
</HTML>
stringbuilder 2006-02-28
  • 打赏
  • 举报
回复
很简单的,两个页面,第一个webform1.aspx

<HTML>
<HEAD>
<title>showFrame</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script>
function toDownload()
{
iframe1.document.location="downLoad.aspx?valuedata='北京测试系统有限公司'";
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<A onclick="toDownload()" href="#">toDownload</A>
<iframe id="iframe1" name="iframe1" src="blank.aspx" height="0">
</iframe>
</form>
</body>
</HTML>
theodiact 2006-02-28
  • 打赏
  • 举报
回复
最好能够把问题描述的详细点,要不真的不太明白
fantasylu 2006-02-28
  • 打赏
  • 举报
回复
搂主,是不是使用了重写HttpHead的方式进行下载

因为你重写了HttpHead,所以Javascript都不能用

线程错误就不知道啦,是否读取文件后,没有关闭流
accpyy 2006-02-28
  • 打赏
  • 举报
回复
关注
stringbuilder 2006-02-28
  • 打赏
  • 举报
回复
难道所有的人都不知道吗?

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧