Which Persistence Approach Should I Use with Crystal Reports?

When planning a Web application to build with the Crystal Reports SDK, one of your most important considerations is which persistence approach to use. Learning the SDK fundamentals that affect persistence helps you choose the best structure for your Crystal Reports for Visual Studio project.

What is persistence?

Web pages do not preserve state (the status and information of a user connecting to a website). Each Web page is requested from a server, sent to the user, and the process is then terminated. This is fine when reading text information, but problematic when designing a Web application that needs to preserve information about a user across page reloads and redirects.

Persistence refers to the use of a mechanism to preserve state for each user (such as the current report page being viewed by each user) unhindered by page reloads and redirects.

Best practices for persistence

In this section, you explore best practices for persisting changes made to a Crystal report on a Web page while that report is refreshed during a Web page reload. The change that needs to be persisted may be as simple as going to the second page after the report viewer's Next Page button has been clicked, or as complex as displaying entirely different data after a report's parameters have been changed.

In Crystal Reports for Visual Studio, persistence must be applied to the following things:

  • The CrystalReportViewer control.
  • The report that is bound to the CrystalReportViewer control.

Ways of persisting state in ASP and ASP.NET

In traditional ASP and ASP.NET, the state is maintained by either the Web browser or the Web server, in the following ways.

Environment
Client or server?
Name
Method
ASP*
Client browser
Form fields
Pass name/value pairs across Web pages through form submission fields.
ASP*
Client browser
URL arguments
Pass name/value pairs across Web pages using URL arguments.
ASP*
Client browser
Cookie
Assign name/value pairs to a cookie on the client browser, and then retrieve the cookie in a new page.
ASP*
Web server
Session object
Assign instantiated objects to the Session object on the server, and then retrieve from Session in a new page.
ASP*
Web server
Application object
Assign instantiated objects to the Application object on the server, and then retrieve from Application in a new page.
ASP.NET
Client browser
ViewState object
Assign string values to the ViewState object of the ASP.NET Web Form.
ASP.NET
Web server
Cache object
Same as Application object, but with enhanced features.

* All ASP persistence approaches continue to work in ASP.NET.

Which persistence approaches work best with Crystal Reports?

The most appropriate persistence approaches to use with Crystal Reports are ViewState, Session, or Cache.

In this section: