下载文件表单服务器时出错 [英] Error in Downloading a file Form Server

查看:177
本文介绍了下载文件表单服务器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我已经设计了一个应用程序,可以在其中上载并下载文件,当我单击行"按钮以下载文件时,回发触发器并下载了文件,但是问题是当文件被下载时,UI字体变为更大的PLZ建议克服此错误



链接上的代码单击

Hi i Have Designed a application in which i wil be uploading and Downloadint the File, When i Click a LInk Button to download a file a Post Back triggers and file is downloaded But the Prolem is when file is downloaded my UI Font becomes Bigger plz suggest to over come from this error



Code on Link Click

Protected Sub lnkAttach_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAttach.Click
        Dim jscript As String
        Dim download As String
        download = "download.aspx?FileId=" & lnkAttach.Text
        jscript = "<script>"
        jscript = jscript & "var winPrint=window.open('" & download & "', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');" & vbCrLf
              jscript = jscript & "</script>"

        HttpContext.Current.Response.Write(jscript)

    End Sub





在download.aspx中的代码





Code In the download.aspx

Dim strURL As String = "fileServer/" & Request.QueryString("FileId")

 Dim req As New WebClient()
 Dim response As HttpResponse = HttpContext.Current.Response
 response.Clear()
 response.ClearContent()
 response.ClearHeaders()
 response.Buffer = True
 response.AddHeader("Content-Disposition", "attachment;filename=" + Server.MapPath(strURL) + "")
 Dim data As Byte() = req.DownloadData(Server.MapPath(strURL))
 response.BinaryWrite(data)
 response.[End]()

推荐答案

而不是直接将其写入响应流,请尝试以下操作.

Instead of writing it directly to the response stream, try the following.

Dim downloadURL As String = String.Format("window.open('download.aspx?fileID={0}','_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=400, height=400');", lnkAttach.Text)

ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "download-file", downloadURL, True)  



试试这个,让我知道它是否有效.



Try this and let me know if it works.


这篇关于下载文件表单服务器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆