Where to post? Multiple Reports with ReportViewer and SSRS 2008 in Silverlight RRS feed

  • Question

  • There is a lot of information out there about using the ReportViewer control in Silverlight to display multiple reports but I can't get any of them to work for me in my situation because the way I have everything set up is a little different. We had to be able to send post data to the page the ReportViewer is on so a little bit of javascript had to be added in to actually open the page.

    Most of the info online talks about just adding the line ReportViewerCtrl.reset() and it should work but for me it makes absolutely no difference. I'm fairly confident the code will explain the situation better but if you need more details about the set up, please, just ask.

    So... from the beginning... the hyperlink button for the report calls this on click: HtmlPage.Window.Invoke("showAspPage", par);

    That calls this script (I have cut out everything that handles the report parameters and stuff because it works just the same when that data is excluded anyway):

        <script type="text/javascript">
    var g_htmlWindow;

    function showAspPage(param) {
    var to = param["to"];
    var myForm = document.createElement("form");
    .method = "post";
    .action = to;
    .setAttribute("target", "_blank");  

    //handle parameters here


    param["to"] is the link to the page the actual ReportViewer control is on... so from the aspx portion of that page:

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer4" runat="server"> </rsweb:ReportViewer>

    And the important chunk from the aspx.cs portion of the ReportViewer page... (might be over-kill on setting properties and such but I've added a lot of stuff while trying out what suggestions I found on the web)

    ReportViewer4.ShowCredentialPrompts = false;
    ReportViewer4.ServerReport.ReportServerCredentials = new ReportCredentials();
    ReportViewer4.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
    ReportViewer4.ServerReport.ReportServerUrl = reportServerURL
    ReportViewer4.AsyncRendering = false;

    ReportViewer4.ServerReport.ReportPath = reportPath;
    ReportViewer4.KeepSessionAlive = true;


    ReportViewer4.SizeToReportContent = true;
    ReportViewer4.Width = Unit.Pixel(900);

    When I only want to see one report, everything works fine - everything is set up correctly. But, when I want to call HtmlPage.Window.Invoke("showAspPage", par); twice in a row for two different reports I start getting this error either when one of the reports loads or when you try and change the report parameters in either of the two reports: ASP.NET session has expired or could not be found Both reports load 95% of the time - with parameters, data, everything; one report always loads but it depends on which one finishes loading first; but you can't change the parameters without that error.

    So.... as a slight alternative, in this situation, the ability to change the report isn't actually needed and I could do a direct export to PDF but with scripting involved you can't simply add "rs:Format=PDF" to the end of the report path. However, if the parameters are visible, they need to work if changed. I guess I could hide the whole parameter section? But it still doesn't solve the issue of getting the error when the report loads sometimes....

    Also.... might be entirely unrelated, but the parameters are encrypted and I have to get the salt and hash from the database (Entity Framework and WCF RIA Services) before I call HtmlPage.Window.Invoke.... I find this kind of weird.... but, after the report screen loads, if the user sits there and doesn't click on anything (but doesn't sit there long enough to actually be logged out, maybe just 5 min or so), I get this error: 'Load operation failed for query 'GetStuff'. The remote server returned an error: Not Found.' but again, it works fine if clicked right away. I've never had that happen until I started this two reports at once thing, though.

    Please... any advice.... or suggestions... or alternatives... or links...


    So... I tried to just hide the whole parameters section but the user still needs to be able to print and export. It works fine for one of the reports but on the other one I get this on the whole window (when exporting to PDF for both reports):

    [AspNetSessionExpiredException: ASP.NET session has expired or could not be found] Microsoft.Reporting.WebForms.ViewerDataOperation..ctor() +330 Microsoft.Reporting.WebForms.ReportDataOperation..ctor(Boolean requiresFullReportLoad) +120 Microsoft.Reporting.WebForms.ReportDataOperation..ctor() +33 Microsoft.Reporting.WebForms.ExportOperation..ctor() +29 Microsoft.Reporting.WebForms.HttpHandler.GetHandler(String operationType) +188 Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +111 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

    Wednesday, April 6, 2011 7:40 PM