ReportViewer - Export functionality does not working RRS feed

  • Question

  • User1459882081 posted

    Hi Folks,

    I am using Microsoft.Reporting.WebForms ReportViewer to our web reports in a .aspx web page. We embed this web page to the desktop application using web browser control. Everything works well but the export functionality. When I select a format (Excel or PDF) and click "Export" link button, it ends up giving me this error.

    ASP.NET session has expired
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Microsoft.Reporting.WebForms.AspNetSessionExpiredException: ASP.NET session has expired

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:

    [AspNetSessionExpiredException: ASP.NET session has expired]
       Microsoft.Reporting.WebForms.ReportDataOperation..ctor() +754
       Microsoft.Reporting.WebForms.HttpHandler.GetHandler() +335
       Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +20
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

    However this works fine if I do this directly from the web page (using browser). The problem persists only in case of desktop application (where we embed this web page using web browser control).

    Please help me on this, highly appreciated. Thanks. 

    Wednesday, February 9, 2011 10:00 AM

All replies

  • User-359936451 posted

    I think the reason this happens is because you don't have an actual web server, serving the page source. You'll need to code this in the language of your desktop app to open Excel and export data.

    Can you post some of the ASP source code though. Perhaps there is a way to runat="local" rather than "Server"


    Wednesday, February 9, 2011 10:40 AM
  • User1459882081 posted

    Here is the structure of the page:

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Reports.ascx.vb" Inherits="Main.AccountReports" %>

    <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b0erf5frer0a3a"
        Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
    <% %>
    <div class="accountOverviewReport" >
            <rsweb:ReportViewer ID="ux_viewReport" runat="server"
                                Width = "100%"


    Wednesday, February 9, 2011 10:44 AM
  • User-359936451 posted

    How about the code that you are currently using to try and export to Excel?


    Wednesday, February 9, 2011 11:11 AM
  • User1459882081 posted

    There is no code related to the "Export" button, it's an in-built feature. 

    Wednesday, February 9, 2011 11:18 AM
  • User-359936451 posted

    What do you have coded in the Reports.ascx.vb code behind file?



    Wednesday, February 9, 2011 11:37 AM
  • User1263071204 posted

    This is a bit late, but I just ran into this same problem.  The issue is that the Export menu launches its items in a new browser window, which by default gets hosted by a new instance of Internet Explorer.  Since it's a separate process, it doesn't have access to the same session, so it reports the error.

    The solution I implemented was to handle the WebBrowser's NewWindow2 and NewWindow3 events so that my application can create a new WebBrowser control to host the new page.  I found an easy way to handle this event for the WebForms WebBrowser control in the CodeProject article 'How to easily capture the NewWindow3 event and detect a JavaScript window.close() call with System.Windows.Forms.WebBrowser' (http://www.codeproject.com/KB/miscctrl/WebBrowserNewWindow2Event.aspx).

    The issue I ran into with this is that I'm not sure when I should close the new browser.  Internet Explorer automatically closes the page when the export operation completes, but I'm not sure what Microsoft uses to determine when to close it.  To work around that issue, I don't display the new browser, esentially adding it to a Panel on the same form that has zero height.  It works fine in the happy path, but may hide some useful details if it ever does fail.

    Thursday, May 26, 2011 5:53 PM