ActiveReportsServer allows you to retrieve the reports list from ActiveReportsServer site using the ReportList control. It also allows you to incorporate the feature of exporting each report into PDF, Word or Excel format in the application developed by the user. This topic explains how to retrieve reports from a site by entering credentials in the log-in screen or through the Web.config file.
Controls for the Log In page
Control | Text Property |
---|---|
Label | User Name: |
TextBox | ? |
Label | Password: |
TextBox | ? |
Button | Log In |
Visual Basic
Visual Basic (Paste INSIDE SessionStorage.vb) |
Copy Code
|
---|---|
Imports System Imports System.Web Namespace App_Code Public Class SessionStorage Private Const SecurityTokenKey As String = "{DEBDB016-040A-48f4-B568-897E6D410919}" Public Shared Property SecurityToken() As String Get Return TryCast(HttpContext.Current.Session(SecurityTokenKey), String) End Get Set(value As String) HttpContext.Current.Session(SecurityTokenKey) = value End Set End Property End Class End Namespace |
C#
C# (Paste INSIDE SessionStorage.cs) |
Copy Code
|
---|---|
using System; using System.Web; namespace App_Code { public static class SessionStorage { private const string SecurityTokenKey = "{DEBDB016-040A-48f4-B568-897E6D410919}"; public static string SecurityToken { get { return HttpContext.Current.Session[SecurityTokenKey] as string; } set { HttpContext.Current.Session[SecurityTokenKey] = value; } } } } |
Visual Basic
Visual Basic (Paste at the top of file) |
Copy Code
|
---|---|
Imports ActiveReports.Server.ReportControls.Servicing Imports App_Code |
C#
C# (Paste at the top of file) |
Copy Code
|
---|---|
using ActiveReports.Server.ReportControls.Servicing; using App_Code; |
Note: An error will be thrown in the following line until you add ActiveReports.Server.ReportControls.dll reference using the steps mentioned in To add the ReportList control to a Web Form.
using ActiveReports.Server.ReportControls.Servicing;
Visual Basic
Visual Basic (Paste INSIDE the button click event) |
Copy Code
|
---|---|
Dim username = TextBox1.Text Dim password = TextBox2.Text Dim reportService = New ReportServiceProxy() SessionStorage.SecurityToken = Nothing Dim securityToken = reportService.Login(username, password, Nothing, False) SessionStorage.SecurityToken = securityToken Server.Transfer("Default2.aspx") |
C#
C# (Paste INSIDE the button click event) |
Copy Code
|
---|---|
var username = TextBox1.Text; var password = TextBox2.Text; var reportService = new ReportServiceProxy(); SessionStorage.SecurityToken = null; var securityToken = reportService.Login(username, password, null, false); SessionStorage.SecurityToken = securityToken; Server.Transfer("Default2.aspx"); |
Note: An error will be thrown in the following line(s) until you add ActiveReports.Server.ReportControls.dll reference using the steps mentioned in To add the ReportList control to a Web Form.
Dim reportService = New ReportServiceProxy()
OR
var reportService = new ReportServiceProxy();
To enable the ASP.NET compatibility mode
ASP.NET code. Paste BETWEEN the <configSections> tab and </configSections> |
Copy Code
|
---|---|
<system.serviceModel> |
Note: These steps are required when using ASP.NET website. You do not need to create .svc file manually in case of ASP.NET Web application, as service file is added automatically when a ReportList control is dropped upon the web form.
To create .svc file for WCF service
ASP.NET code |
Copy Code
|
---|---|
<%@ ServiceHost Service="ActiveReports.Server.ReportControls.Servicing.ReportServiceProxy" Factory="ActiveReports.Server.ReportControls.Servicing.ReportServiceHostFactory" %> |
If you need to add the control to your toolbox, drop down these steps.
Note: The.svc file is not added automatically when using ASP.NET Website. You need to manually add ReportService.svc file by using the above steps mentioned in To create .svc file for WCF service.
Note: The ReportServicePath property is not automatically set when using ASP.NET website. You need to manually set the file path of ReportService.svc.
You can specify the security token and ActiveReports 10 Server host using code in a Global Application Class.
To import Servicing namespace
ASP.NET code. (Paste on the line BELOW the Application Language line) |
Copy Code
|
---|---|
<%@ Import Namespace="ActiveReports.Server.ReportControls.Servicing" %> <%@ Import Namespace="App_Code" %> |
Visual Basic (Paste at the top of Global.asax.vb file) |
Copy Code
|
---|---|
Imports ActiveReports.Server.ReportControls.Servicing Imports App_Code |
C# (Paste at the top of Global.asax.cs file) |
Copy Code
|
---|---|
using ActiveReports.Server.ReportControls.Servicing; using App_Code; |
Visual Basic
Visual Basic (Paste in the Global.asax file AFTER the Application_Start event) |
Copy Code
|
---|---|
Private Shared Sub ResolveRemoteEndpoint(remoteEndpoint As RemoteEndpoint) remoteEndpoint.Address = "http://localhost:8080" remoteEndpoint.SecurityToken = SessionStorage.SecurityToken End Sub |
C#
C# (Paste in the Global.asax file AFTER the Application_Start event) |
Copy Code
|
---|---|
static void ResolveRemoteEndpoint(RemoteEndpoint remoteEndpoint) { remoteEndpoint.Address = "http://localhost:8080"; remoteEndpoint.SecurityToken = SessionStorage.SecurityToken; } |
To provide a handler for the event
C# code. Paste INSIDE the Application_Start event. |
Copy Code
|
---|---|
ReportServiceProxy.ResolveRemoteEndpoint += ResolveRemoteEndpoint; |
You can also specify the user name, password, and ActiveReports 10 Server host in your web application's web.config file.
In the web.config file, add credentials using code like the following.
ASP.NET code. Paste in the web.config file AFTER the </configSections> tag. |
Copy Code
|
---|---|
<configSections> <sectionGroup name="activereports.server"> <section name="reportServiceProxy" type="ActiveReports.Server.ReportControls.Configuration.ActiveReportsServerSection, ActiveReports.Server.ReportControls, Version=9.x.xxxx.1, Culture=neutral, PublicKeyToken=d557f2f30a260da2" allowDefinition="Everywhere" /> </sectionGroup> </configSections> <activereports.server> |
At run time, the ReportList control retrieves all of the reports from ActiveReports 10 Server, and provides buttons to export each to PDF, Word, and ExcelNotw.