ASP.NET MVC Controls > Controls > FlexViewer > ReportViewer > Manually Configuring ReportViewer |
FlexViewer is available as MVC control that can be used in an MVC applications to view reports using C1 Web API Report Services. Complete the following steps to use the control to view a report.
Note: The C1 ASP.NET MVC 5 Web Application and C1 ASP.NET Core MVC Application template for ASP.NET MVC Edition automatically registers the required resources, and adds the relevant references and packages to your application. Therefore, you only need to follow Steps 6 to 8 above if your application is created using ComponentOne template. |
The following image shows a report named Simple List, which can be viewed in FlexViewer on completing the steps above.
Create an ASP.NET Web Application (.NET Framework) using Visual Studio templates. For more information, see Configuring MVC application using Visual Studio template.
licenses.licx |
Copy Code
|
---|---|
C1.Web.Mvc.LicenseDetector, C1.Web.Mvc C1.Web.Mvc.Viewer.LicenseDetector, C1.Web.Mvc.FlexViewers |
Complete the following steps to add the ASP.NET MVC Edition references and FlexViewer references to your project.
Note: Once you have added the resources to ASP.NET Core application, you can license the resources and your application using the GrapeCity License Manager. For more information, see Licensing topic. |
web.config
file to open it.<system.web.webPages.razor></system.web.webPages.razor>
tags.
HTML |
Copy Code
|
---|---|
<add namespace="C1.Web.Mvc" /> <add namespace="C1.Web.Mvc.Viewer" /> <add namespace="C1.Web.Mvc.Viewer.Fluent" /> |
_ViewImports |
Copy Code
|
---|---|
@addTagHelper *, C1.AspNetCore.Mvc @addTagHelper *, C1.AspNetCore.Mvc.FlexViewer |
Complete the following steps to register the required resources for using ASP.NET MVC FlexViewer control:
_Layout.cshtml
to open it.<head></head>
tags.
_Layout.cshtml |
Copy Code
|
---|---|
@Html.C1().Styles() @Html.C1().Scripts().FlexViewer() |
_Layout.cshtml |
Copy Code
|
---|---|
<c1-styles> <c1-scripts> <c1-flex-viewer-scripts /></c1-scripts> |
For more information on how to register resources for FlexViewer, refer to Registering Resources.
Complete the following steps to add controller to your application:
A new controller is added to the application within the folder Controllers.
Controller
)A new controller is added to the application within the folder Controllers.
Complete the following steps to add corresponding view for the controller.
A view is added for the controller. In the code below, we have specified the Service URL, FilePath, and Report Name.
Index.cshtml |
Copy Code
|
---|---|
@(Html.C1().ReportViewer().ServiceUrl(@"http://demos.componentone.com/ASPNET/c1webapi/4.0.20171.91/api/report").FilePath(@"ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr").ReportName(@"Simple List")) |
A view is added for the controller. In the code below, we have specified the Service URL, FilePath, and Report Name.
Index.cshtml |
Copy Code
|
---|---|
<c1-report-viewer file-path="ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr" report-name="Simple List" service-url="http://demos.componentone.com/ASPNET/c1webapi/4.0.20171.91/api/report"> </c1-report-viewer> |
A view is added for the controller.
Note: Append the folder name and view name to the generated URL (for example: http://localhost:1234/Report/Index) in the address bar of the browser to view the report. |
Note: To know further, explore the detailed demo for using FlexViewer. |