Reporting for Web - How to display documents from the Report and Dashboard Server in an ASP.NET MVC application
This example demonstrates how to use the Report and Dashboard Server's API to obtain report/dashboard documents and display them in the Document/Dashboard Viewers.
The table below lists controls that display documents depending on their types:
Document Type | Control | Configuration Options |
---|---|---|
Report | ASP.NET MVC Document Viewer Extension | WebDocumentViewerSettings.SettingsRemoteSource |
Dashboard | ASP.NET MVC Dashboard Extension (in the ViewerOnly mode) | DashboardExtensionSettings.BackendOptions |
Note Before running the example, perform the steps described below in the Report and Dashboard Server Configuration and Application Configuration sections.
-
Configure the Report and Dashboard Server to use the HTTPS protocol.
-
Configure the Email Settings required to verify the email address that you enter when you create a new user account in the next step.
-
Create a user account with Server authentication and give this account permissions to view documents. The account's credentials will be used to obtain a Bearer token, which is required to access the Report and Dashboard Server's API.
-
Enable Cross-Origin Resource Sharing (CORS) on the screen with the General Settings and restart the DevExpress.ReportServer web site in the Internet Information Services (IIS) Manager to apply the changes.
-
In Visual Studio, right-click the solution and select Restore NuGet Packages. You can use the DevExpress Local package source shipped with installation or setup a new package source.
-
Open the
Web.config
file and assign your Report and Dashboard Server's URI to theappSettings/ReportServer:BaseUri
property. -
Create the
Web.SECRETS.config
* file with the following content and specify the API user name and password.<appSettings> <add key="ReportServer:UserName" value="api-user-name" /> <add key="ReportServer:UserPassword" value="api-user-password" /> </appSettings>
Review the following blog post for more details: Best practices for private config data and connection strings.
The page displays a list of reports and dashboards available to the current user on the Report and Dashboard Server. When the user clicks the link, the report (or dashboard) is loaded to the viewer.
- Global.asax.cs
- ReportService.cs
- DashboardService.cs
- HomeController.cs
- Index.cshtml
- ReportViewer.cshtml
- DashboardViewer.cshtml
- Web.config
(you will be redirected to DevExpress.com to submit your response)