Solved

Download file from Database generating PageRequestManagerParserErrorException

Posted on 2012-12-24
1
558 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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