Hi everyone! Kindly please assist me on this issue. I am about to download a file but is shows error
sys.webforms.pagerequestmanagerparsererrorexception the message received from the server could not be parsed
My code is this:
Dim myReader As SqlDataReader = command.ExecuteReader
If myReader.Read Then
Response.BinaryWrite(myReader("Attachment"))
Dim Bytes() = DirectCast(myReader.Item("Attachment"), Byte())
Response.Clear()
Response.AddHeader("Content-Disposition", "inline; attachment; filename=" + fileName)
Response.AddHeader("Content-Type", "Application/octet-stream")
Response.AddHeader("Content-Length", Bytes.Count.ToString())
Response.BinaryWrite(Bytes)
'Response.End()
HttpContext.Current.ApplicationInstance.CompleteRequest()
End If
Calls to Response.Write(): By calling Response.Write() directly you are bypassing the normal rendering mechanism of ASP.NET controls. The bits you write are going straight out to the client without further processing (well, mostly…). This means that UpdatePanel can’t encode the
data in its special format.
Solution:
Calls to Response.Write(): Place an <asp:Label> or similar control on your page and set its Text property. The added benefit is that your pages will be valid HTML. When using Response.Write() you typically end up with pages that contain invalid markup.
Beware of bugs in the above code; I have only proved it correct, not tried it.
-------------------------------------------------------
Contact-Info:Adils.kiet@gmail.com
Saquilicious
0 Points
2 Posts
Could not download file because of Response.Write(). HELP!
Jan 29, 2013 03:00 AM|LINK
Hi everyone! Kindly please assist me on this issue. I am about to download a file but is shows error sys.webforms.pagerequestmanagerparsererrorexception the message received from the server could not be parsed
My code is this:
Dim myReader As SqlDataReader = command.ExecuteReader
If myReader.Read Then
Response.BinaryWrite(myReader("Attachment"))
Dim Bytes() = DirectCast(myReader.Item("Attachment"), Byte())
Response.Clear()
Response.AddHeader("Content-Disposition", "inline; attachment; filename=" + fileName)
Response.AddHeader("Content-Type", "Application/octet-stream")
Response.AddHeader("Content-Length", Bytes.Count.ToString())
Response.BinaryWrite(Bytes)
'Response.End()
HttpContext.Current.ApplicationInstance.CompleteRequest()
End If
myReader.Close()
Jugg3rNaut
Member
474 Points
109 Posts
Re: Could not download file because of Response.Write(). HELP!
Jan 29, 2013 03:24 AM|LINK
i have found this for you
Problem:
Calls to Response.Write():
By calling Response.Write() directly you are bypassing the normal rendering mechanism of ASP.NET controls. The bits you write are going straight out to the client without further processing (well, mostly…). This means that UpdatePanel can’t encode the data in its special format.
Solution:
Calls to Response.Write():
Place an <asp:Label> or similar control on your page and set its Text property. The added benefit is that your pages will be valid HTML. When using Response.Write() you typically end up with pages that contain invalid markup.
-------------------------------------------------------
Contact-Info:Adils.kiet@gmail.com
Saquilicious
0 Points
2 Posts
Re: Could not download file because of Response.Write(). HELP!
Jan 29, 2013 04:51 AM|LINK
I already found the solution. I put this code on page load.
Dim scriptManager As ScriptManager = scriptManager.GetCurrent(Me.Page)
scriptManager.RegisterPostBackControl(rgAttach)
THANKS!