Solved

Download file from Database generating PageRequestManagerParserErrorException

Posted on 2012-12-24
1
552 Views
Last Modified: 2012-12-24
I am trying to download a file from my database to my webform. The file downloads fine, but when I click a link on the page to go to another page, I'm getting this error:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

I've tried two different methods of displaying the file.

1) Using a .ashx IHttpHandler with:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

      Dim id As Integer = CInt(context.Request.QueryString("ID"))
      context.Response.Clear()
      context.Response.ClearContent()
      context.Response.ClearHeaders()

<snip code to retrieve from dbf>

         context.Response.ContentType = contentType
         context.Response.AddHeader("Content-Disposition", "attachment; filename=" + UploadedFileName)
         context.Response.BinaryWrite(data)
         context.Response.Flush()
         context.Response.[End]()

Open in new window


And 2)
With a webform page and this in code behind (snipped):

   Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

      ' Get the file id from the query string
      Dim id As Integer = Convert.ToInt16(Request.QueryString("ID"))

<snip code to retrieve from dbf>

         ' Send the file to the browser
         Response.AddHeader("Content-type", contentType)
         Response.AddHeader("Content-Disposition", "attachment; filename=" + UploadedFileName)
         Response.BinaryWrite(data)
         Response.Flush()
         Response.[End]()

Open in new window


Again, it is downloading the file perfectly. It's just when I attempt to click my grid to load another record, it errors as above.

Any ideas?

thanks!
0
Comment
Question by:BobCSD
1 Comment
 
LVL 1

Accepted Solution

by:
BobCSD earned 0 total points
ID: 38719516
I was using a LinkButton in my grid and the postback generated the error.

I changed it to a simply label a href / hyperlink and it works fine now.

thanks!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Showdialog 8 21
Convert to Hour/minute textbox and compare 3 36
Cannot upload files above 1mb IIS7 11 16
Open a word document 23 18
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now