页面执行/生命周期在Response.TransmitFile之后停止 [英] Page execution / lifecycle stops after Response.TransmitFile

查看:63
本文介绍了页面执行/生命周期在Response.TransmitFile之后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有每行的gridview和下载按钮。

页面目标是列出与之相关的所有记录物理文件,单击下载按钮时,应下载并打开下载的文件。这些文件是'pdf'格式。



页面已编码,一切正常。我想在下载文件时重新绑定gridview。但是在下载之后,页面的其余部分的执行或生命周期都没有完成。



似乎问题出在页面处理程序上。我尝试通过互联网搜索,但遗憾的是没有找到解决方案。我请求专家,请帮我解决这个问题。

我的代码如下。



Hi
I have a gridview and a download button for each and every row.
the page objective is to list out all the records related to physical files, and when download button clicked it should download and open the downloaded file. the files are in 'pdf' format.

The page is coded and everything is going fine. I want to rebind the gridview when the file got downloaded. but after download, the rest of the page's execution or lifecycle is not being done.

it seems the issue is with page handlers. I tried searching over the internet, but unfortunately no solution found. I request you experts please help me in this issue.
and my code is like below.

Dim archiveLG() As String = fileName.Split("-")
                Hos.ArchiveLG(archiveLG(0).Substring(1), archiveLG(1).Replace(".pdf", ""))

                grdLGs.DataBind()










Dim outputStream As FileStream = New FileStream((Server.MapPath("../ScannedDoc") + ("\\" + fileName)), FileMode.Create)
                    reqFTP = CType(FtpWebRequest.Create(New Uri(DataDirectory + "InternalDocuments/" + folderName + "/" + fileName)), FtpWebRequest)

                    reqFTP.Method = WebRequestMethods.Ftp.DownloadFile
                    reqFTP.UseBinary = True
                    reqFTP.Credentials = New NetworkCredential(uid, pwd)
                    Dim ftpresponse As FtpWebResponse = CType(reqFTP.GetResponse, FtpWebResponse)

                    Dim ftpStream As Stream = ftpresponse.GetResponseStream
                    Dim cl As Long = ftpresponse.ContentLength
                    Dim bufferSize As Integer = 2048
                    Dim readCount As Integer
                    Dim buffer() As Byte = New Byte((bufferSize) - 1) {}
                    readCount = ftpStream.Read(buffer, 0, bufferSize)

                    While (readCount > 0)
                        outputStream.Write(buffer, 0, readCount)
                        readCount = ftpStream.Read(buffer, 0, bufferSize)

                    End While
                    ftpStream.Close()
                    outputStream.Close()
                    ftpresponse.Close()

                    Dim responseFile As String = Server.MapPath("../ScannedDoc") + ("\\" + fileName)
                    Response.ContentType = "application/pdf"
                    Response.AppendHeader("Content-Disposition", ("attachment; filename=" + fileName))
                    Response.TransmitFile(responseFile)
                    Response.Flush()





提前致谢。

Sri



Thanks in advance.
Sri

推荐答案

嗯,问题的标题应该有些不同,因为Page lifecycle不会停止这个场景。



实际上你试图点击gridview中的按钮。所以你试图抓住那个按钮的点击事件(据我所知)问题),请参考下面的链接,它描述了如何处理gridview内的按钮。



如何:响应GridView控件中的按钮事件 [ ^ ]



获取按钮建议的单击事件并执行适当的操作在那里。



问候......:)
Well,the title of the question should be somewhat different because Page lifecycle doesnt stop in this scenario.

Actually you are trying to click the button that resides in a gridview.So you are trying to catch the click event of that button(As per i understand the question),so refer to below link which describes how to handle buttons inside gridview.

How to: Respond to Button Events in a GridView Control[^]

Get the click event of that button as suggested and perform appropriate operations there.

Regards... :)


这篇关于页面执行/生命周期在Response.TransmitFile之后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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