Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 885099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:51:12+00:00 2026-05-15T12:51:12+00:00

I’m trying to fix an issue with an application I’m supporting (I didn’t write

  • 0

I’m trying to fix an issue with an application I’m supporting (I didn’t write the code). The code takes an SSRS report and renders it in pdf format. Users are sporadically getting the error indicated in the title. There is no rhyme or reason to when the error is generated (a particular report will run one time and throw the error the next). The code is below.

  Public Sub OpenReport()
        Dim MyParms As New Generic.List(Of ReportParameter)
        Dim mimeType As String = Nothing
        Dim encoding As String = Nothing
        Dim extension As String = Nothing
        Dim deviceInfo As String = Nothing
        Dim streamids() As String = Nothing
        Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
        Dim bytes() As Byte 
        Dim format As String = "PDF" ''#to open the report in pdf; report viewer invisible

        Try
            If dropReports.SelectedItem.Value = "1" Then

                If Session("IsBDAP") = True Then
                    MyParms.Add(New ReportParameter("SCAId", dropSCA.SelectedItem.Value, False))
                Else
                    MyParms.Add(New ReportParameter("SCAId", Server.UrlEncode(Session("SCAId")), False))
                End If
                MyParms.Add(New ReportParameter("ProviderId", dropProvider.SelectedItem.Value, False))
                If dropVisit.Visible = True Then
                    MyParms.Add(New ReportParameter("VisitId", dropVisit.SelectedItem.Value, False))
                End If
                MyParms.Add(New ReportParameter("FY", dropContractFY.SelectedItem.Value, False))

                ReportViewer1.ProcessingMode = ProcessingMode.Remote
                ReportViewer1.ServerReport.ReportServerUrl = New Uri(System.Configuration.ConfigurationManager.AppSettings("ReportServerURI"))
                ReportViewer1.ServerReport.ReportPath = Session("ReportsFolder") & "MReport"
                ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
                ReportViewer1.ServerReport.SetParameters(MyParms)
                ''#Code to convert the report to pdf 
                deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"
                bytes = ReportViewer1.ServerReport.Render(format, deviceInfo, mimeType, encoding, extension, streamids, warnings)
                Dim size As Integer = bytes.Length
                ReportViewer1.ServerReport.Refresh()
                Response.Buffer = True
                Response.Clear()
                Response.ContentType = mimeType
                Response.AddHeader("content-disposition", "attachment; filename=MReport." + extension)
                Response.BinaryWrite(bytes)


            ElseIf dropReports.SelectedItem.Value = "2" Then

                If Session("IsBDAP") = True Then
                    MyParms.Add(New ReportParameter("SCAId", dropSCA.SelectedItem.Value, False))
                Else
                    MyParms.Add(New ReportParameter("SCAId", Server.UrlEncode(Session("SCAId")), False))
                End If
                MyParms.Add(New ReportParameter("ProviderId", dropProvider.SelectedItem.Value, False))
                If dropVisit.Visible = True Then
                    MyParms.Add(New ReportParameter("FollowUpVisitId", dropVisit.SelectedItem.Value, False))
                End If
                MyParms.Add(New ReportParameter("FY", dropContractFY.SelectedItem.Value, False))

                ReportViewer1.ProcessingMode = ProcessingMode.Remote
                ReportViewer1.ServerReport.ReportServerUrl = New Uri(System.Configuration.ConfigurationManager.AppSettings("ReportServerURI"))
                ReportViewer1.ServerReport.ReportPath = Session("ReportsFolder") & "FReport"
                ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
                ReportViewer1.ServerReport.SetParameters(MyParms)
                ''#Code to convert the report to pdf 
                deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"
                bytes = ReportViewer1.ServerReport.Render(format, deviceInfo, mimeType, encoding, extension, streamids, warnings)
                ReportViewer1.ServerReport.Refresh()
                Response.Buffer = True
                Response.Clear()
                Response.ContentType = mimeType
                Response.AddHeader("content-disposition", "attachment; filename=FReport." + extension)
                Response.BinaryWrite(bytes)

I read that the default length limit is 4MB. None of the reports by themselves are even over 350K. I’m wondering if this could be caused by a caching issue. I’m not an expert, so I need some guidance as to how best to solve the problem. I also want to understand why the issue is happening. Please note that only 2 reports are shown in the snippet – there are about 30+ reports in the full sub.

Thanks for your help.

edit – I tried the proposed solution, but it didn’t help (I also tried the Fiddler route, but did not see anything glaring). I thought it might be best to clarify. The reports will run fine for a while, but the execution time gradually gets slower and slower until the application eventually displays the error. Does this shed any light on the problem?

TIA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:51:13+00:00Added an answer on May 15, 2026 at 12:51 pm

    Ok, I figured it out…finally. Here’s the cause (for anyone with a similar problem). The issue is viewstate. The reportviewer on the page is adding millions of bytes to viewstate, causing the issue. I disabled viewstate for the hidden reportviewer and no longer have the issue. Thank you to everyone for your help and suggestions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.