我有以下情况:
Microsoft Report Viewer 2010 用于在 ASP.NET Web 应用程序中以本地模式显示报告(.rdlc 文件)。报表数据是通过在 ASPX 页面后面的代码中分配数据源来提供的。这是一个例子:
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);
}
通常这很好用,我们加载的每个报告都很好。
当我让页面保持打开状态直到工作进程回收,然后尝试刷新报告或在报告页面上执行任何类型的回发时,我收到一个(未处理的)异常“ASP.NET 会话已过期”。
异常信息:异常类型:AspNetSessionExpiredException 异常消息:Die ASP.NET-Sitzung ist abgelaufen oder konnte nicht gefunden >werden。在 Microsoft.Reporting.WebForms.ViewerDataOperation..ctor() 在 Microsoft.Reporting.WebForms.HttpHandler.GetHandler(String operationType) 在 Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) 在 >System.Web.HttpApplication.CallHandlerExecutionStep .System.Web.HttpApplication.IExecutionS>tep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& >completedSynchronously)
IIS 设置为每天早上 5 点回收 我们使用 web.config 中的 InProc 设置,因此很明显,会话丢失了。如果我正确理解了 ASP.NET 行为,则未处理的异常应该会导致工作进程终止。下一个请求到达时应该有一个新的工作进程。
如果会话超时设置较低,则会导致相同的异常。这看起来很奇怪,因为根据我的阅读,报告查看器应该 ping 服务器以保持会话处于活动状态。
我试图捕捉异常,但在我在页面加载中访问它之前,它被抛出在 ReportViewer 控件内的某个地方。如果我取出IsPostBack,上面的代码仍然会执行,但它没有效果。
我尝试使用状态服务器而不是将会话保留在进程中,因此它不会丢失它的会话,但这会导致报告查看器出现其他错误。它似乎无法将其会话数据存储在状态服务器中。
环境为 Windows Server 2003 .NET 4.0 Report Viewer 2010
我在哪里可以处理错误而不终止工作进程,或者让报告使用状态服务器?