Assembly: Microsoft.ReportViewer.WebForms (in microsoft.reportviewer.webforms.dll)
When implementing the IReportServerCredentials interface, it is important know that the ReportViewer control stores the instance of the object in ASP.NET session. If the server's ASP.NET session is being stored out of process, such as in Reporting Services, the class must be marked Serializable so that it may be serialized for storage.
Although it is not required, it is also a good practice to implement the IReportServerCredentials interface as a stateless object. This prevents the credential information, such as user name and password, from being stored when the object is serialized.
For more information about how to specify credentials with the ReportViewer control, see Specifying Connections and Credentials for the ReportViewer Web Server Control.
The following example provides an implementation of IReportServerCredentials that is marked Serializable so that it can be serialized for storage. The credential information is retrieved from the Web.config file. This implementation will connect to the report server with the same credentials for all client requests.
Before using the example, three key value pairs must be added to the application's Web.config file in the appSettings block: MyReportViewerUser, MyReportViewerPassword, and MyReportViewerDomain. These values correspond to the user name, password, and domain that will be used to connect to the report server.