ASP.NET MVC Controls | ComponentOne
Working with Controls / FlexViewer / ReportViewer / Using C1 MVC ReportViewer Template
In This Topic
    Using C1 MVC ReportViewer Template
    In This Topic

    This topic describes how to view a FlexReport in your MVC application using C1 MVC ReportViewer template. C1 MVC ReportViewer template provides three different options by which you can preview your report in FlexViewer;

    Working with C1 MVC ReportViewer

    The below steps demonstrates how you can use C1 MVC ReportViewer wizard to view a report in FlexViewer control using Visual Studio template.

    1. License your application
    2. Register Resources
    3. Add Controller
    Note: The C1 ASP.NET MVC 5 Web Application template for ASP.NET MVC Edition automatically registers the required resources, and adds the relevant references and packages to your application. Therefore, you can directly use the C1 MVC ReportViewer template if your application is created using ComponentOne template.

    License your application

    1. In the Solution Explorer, right click the project and select Add | New Item. The New Item dialog appears.
    2. In the New Item dialog, select C# | General and select Text File in the right pane.
    3. Name the text file as licenses.licx.
    4. In the licenses.licx file, add the following:
      licenses.licx
      Copy Code
      C1.Web.Mvc.LicenseDetector, C1.Web.Mvc
      C1.Web.Mvc.Viewer.LicenseDetector, C1.Web.Mvc.FlexViewer
      

      Note: In case you are working with ASP.NET Core application, you can license the resources and your application using the MESCIUS License Manager Extension. For more information, see Licensing topic.

    Back to Top

    Register Resources

    Complete the following steps to register the required resources for using ASP.NET MVC FlexViewer control:

    1. From the Solution Explorer, open the folders Views | Shared.
    2. Double click _Layout.cshtml to open it.
    3. Add the following code between the <head></head> tags.
      _Layout.cshtml
      Copy Code
      @Html.C1().Styles()
      @Html.C1().Scripts().Basic().FlexViewer()
      

    For more information on how to register resources for FlexViewer, refer to Registering Resources.

    Back to Top

    Add Controller

    Complete the following steps to add controller to your application.

    1. Right click the Controllers folder and select Add | New Scaffolded Item....
    2. In the Add Scaffold wizard select MVC5 Controller - Empty, and click Add.
    3. Provide a name to the Controller. For example, we name the controller as ReportController.

    A new controller is added to the application within the folder Controllers.

    Back to Top