Solved

Download file from Database generating PageRequestManagerParserErrorException

Posted on 2012-12-24
1
554 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:Starr Duskk
1 Comment
 
LVL 1

Accepted Solution

by:
Starr Duskk 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

17 Experts available now in Live!

Get 1:1 Help Now