I have the following situation:
Microsoft Report Viewer 2010 is used to display reports (.rdlc files) in local mode in an ASP.NET web application. The report data is supplied by assigning a datasource in the code behind of an ASPX page. Here's an example:
if(!IsPostBack){
ReportViewer1.Reset();
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataContainerType";
reportDataSource.Value = DatasourceOnPage;
reportDataSource.DataSourceId = "DatasourceOnPageID";
reportDataSource.DataMember = "DataSourceView";
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.DisplayName = "ReportName";
ReportViewer1.LocalReport.ReportEmbeddedResource = "Reportfile.rdlc";
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
}
Normally this works great, every report we have loads just fine.
When I leave the page open until the worker process recycles, then try to refresh the report or do any kind of postback on the report page, I get an (unhandled) exception "ASP.NET Session has expired".
Exception information: Exception type: AspNetSessionExpiredException Exception message: Die ASP.NET-Sitzung ist abgelaufen oder konnte nicht gefunden werden. at Microsoft.Reporting.WebForms.ViewerDataOperation..ctor() at Microsoft.Reporting.WebForms.HttpHandler.GetHandler(String operationType) at Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
IIS is set to recycle every morning at 5 a.m. We use the InProc setting in the web.config, so obviously, the session is lost. If I understand the ASp.NET 2.0 behaviour correctly, the unhandled exception should cause the worker process to terminate. There should be a new worker process when the next request arrives. Somehow this seems to affect our Sitemap Provider, because on the production system, almost every time (but not always), the TreeView and SiteMapPath controls stop displaying the sitemap, but throw no errors. This is very bad, because the users can not recover from this state without the admins recycling the application pool.
If the session timeout setting is low, it causes the same exception. This seems odd, because from what I read, the Report Viewer should ping the server to keep the session alive.
I tried to catch the exception, but it is thrown somewhere inside the ReportViewer control, before I get to access it in page load. The code above is still executed if I take out the IsPostBack, but it has no effect.
I tried using state server instead of keeping the session in the process, so it would not lose it's session, but this leads to other errors from the report viewer. It seemed to be unable to store it's session data in the state server.
The environment is Windows Server 2003 .NET 4.0 Report Viewer 2010
Where can I either handle the error, without having the worker process terminate, or get the report to use stateserver?
Help me Stack Overflow, you're my only hope!