?
Solved

Download file from Database generating PageRequestManagerParserErrorException

Posted on 2012-12-24
1
Medium Priority
?
560 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 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