response.write

ASP.net memory usage during download

一个人想着一个人 提交于 2019-11-28 09:29:23
On an ASP.net site at my place of work, the following chunk of code is responsible for handling file downloads (NOTE: Response.TransmitFile is not used here because the contents of the download are being streamed from a zip file): private void DownloadFile( Stream stream) { int bytesRead; int chunkSize = 1048576; //1MB byte[] readBuffer = new byte[chunkSize]; while ((bytesRead = stream.Read(readBuffer, 0, readBuffer.Length)) != 0) { if(!Response.IsClientConnected) break; byte[] chunk = new byte[bytesRead]; Array.Copy(readBuffer,0,chunk,0,bytesRead); Response.BinaryWrite(chunk); Response.Flush(

Response.Write and UpdatePanel

给你一囗甜甜゛ 提交于 2019-11-27 22:57:05
I generate a vcard that I send to the client using the following code snippet: Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", fileNameOnly)); Response.ContentType = "text/x-vcard"; Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1"); Response.Write(vCard.ToString()); Response.End(); However, I need to use vCards on a page that has the control inside and UpdatePanel. Unfortunately, according to Update panel and Response write this does not work and causes an error. I am wondering what are some alternative ways to send the contents of the vcard/file

ASP.net memory usage during download

蹲街弑〆低调 提交于 2019-11-27 02:58:07
问题 On an ASP.net site at my place of work, the following chunk of code is responsible for handling file downloads (NOTE: Response.TransmitFile is not used here because the contents of the download are being streamed from a zip file): private void DownloadFile( Stream stream) { int bytesRead; int chunkSize = 1048576; //1MB byte[] readBuffer = new byte[chunkSize]; while ((bytesRead = stream.Read(readBuffer, 0, readBuffer.Length)) != 0) { if(!Response.IsClientConnected) break; byte[] chunk = new

Response.Write and UpdatePanel

放肆的年华 提交于 2019-11-26 21:15:43
问题 I generate a vcard that I send to the client using the following code snippet: Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", fileNameOnly)); Response.ContentType = "text/x-vcard"; Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1"); Response.Write(vCard.ToString()); Response.End(); However, I need to use vCards on a page that has the control inside and UpdatePanel. Unfortunately, according to Update panel and Response write this does not work

ASP.Net Download file to client browser

↘锁芯ラ 提交于 2019-11-26 16:33:00
I'm writing a simple test page to download a text file to a browser on button click. I am getting a really strange error that I have never seen before. Any thoughts? The error occures on 'Response.End();' and the file never gets to the client browser Code: string filePath = "C:\\test.txt"; FileInfo file = new FileInfo(filePath); if (file.Exists) { Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "text/plain"; Response.TransmitFile(file.FullName); Response

ASP.Net Download file to client browser

让人想犯罪 __ 提交于 2019-11-26 04:49:18
问题 I\'m writing a simple test page to download a text file to a browser on button click. I am getting a really strange error that I have never seen before. Any thoughts? The error occures on \'Response.End();\' and the file never gets to the client browser Code: string filePath = \"C:\\\\test.txt\"; FileInfo file = new FileInfo(filePath); if (file.Exists) { Response.ClearContent(); Response.AddHeader(\"Content-Disposition\", \"attachment; filename=\" + file.Name); Response.AddHeader(\"Content