Embed AR designer in Single page application

Posted by: xuan.nguyen on 4 July 2024, 6:03 am EST

    • Post Options:
    • Link

    Posted 4 July 2024, 6:03 am EST - Updated 4 July 2024, 6:09 am EST

    Hi all,

    I am using AR18. And my task is embed ActiveReports Designer to my project.

    My propject is single page application (.net framework 4.7.2)



    I see the AR’s document doesn’t have guide one for that ( I only found the guide for MVC App).

    So I have no idea for deal with it.

    Currently, I stuck with this error when I click the ‘preview’ button or others button. The Api will return error code 404.

    I also want to save the report to database (by byte datatype) and load report from database (I don’t need physical files). But I still don’t know how to do that.

    I create a new project and replicate my issue in this one as a sample. I think that will make you easier to follow:

    https://drive.google.com/file/d/15y-442v_atAZcEjfVQCDTfEd3T6P8y38/view?usp=sharing

    What should i do ? Please guide me.

    Thank you so much.

  • Posted 7 July 2024, 9:49 pm EST

    Hi Xuan,

    AFAIK there’s no way to integrate the ActiveReports Web Designer in a non-MVC ASP.NET project.

    Apologies for the inconvenience.

    Regards,

    Anand

  • Posted 7 July 2024, 10:34 pm EST - Updated 7 July 2024, 10:42 pm EST

    Hi Anand,

    I see the Single page application using MVC pattern. Use MVC’s controller as shown below.

    I want to embed the AR web designer to the project. For example, in the login page

    The structure of Single page application is little different than basic MVC app. I follow the guide AR for MVC but still get error as the sample project I provided in previous post.

    Please double check whether Single page application can embed AR web designer? I need your confirmation to raise to my boss.

    Thanks,

  • Posted 9 July 2024, 4:47 am EST

    Hi Xuan,

    We were able to notice this issue with an ASP.NET MVC (.NET Framework) project as well, therefore, we have escalated this issue to our development team (Ticket ID: AR-33810) for their insights on the same and will let you know of any updates we have from them.

    Thanks,

    Anand

  • Posted 9 July 2024, 5:07 am EST

    Hi Anand,

    Thank you so much. I will wait your result.

    Regards,

    Xuan

  • Posted 11 July 2024, 6:37 am EST

    Hi Anand,

    Have you found a solution to this issue yet? We really need it urgently.

    Regards,

    Xuan

  • Posted 12 July 2024, 6:31 am EST

    Hi Xuan,

    As per the developers for an MVC project you’ll need to modify the Routes to:

    public static void RegisterRoutes(RouteCollection routes)
    
            {
    
    			routes.MapMvcAttributeRoutes();
    			//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                //routes.MapRoute(
                //name: "Default",
                //url: "{controller}/{action}/{id}",
                //defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                //);
            }
    

    And replace this in the Web.config file:

     <system.web>
        <compilation debug="true" targetFramework="4.8" />
        <httpRuntime targetFramework="4.8" requestPathInvalidCharacters="" relaxedUrlToFileSystemMapping="true" maxRequestLength="104857600" />
      </system.web>
        <system.webServer>
        <security>
          <requestFiltering allowDoubleEscaping="true" />
        </security>
        <handlers>
          <add name="AllUris" path="*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode" />
        </handlers>
      </system.webServer>
    

    We have created a new MVC .NET Framework project following the steps in our documentation and making the above-mentioned changes and attached the project to this case.

    You can find the designer in the index.html file: https://localhost:44328/index.html

    Regards,

    Anand

    WebApplicationMVC.zip

  • Posted 14 July 2024, 9:34 pm EST - Updated 14 July 2024, 9:39 pm EST

    Hi Anand,

    Thanks for your response.

    After following your guidance. The design worked, and the APIs worked well too.

    But my app will get errors (like your sample):



    I need my app and AR web designer work together. For example, like this:



    Do you have any solution for that?

    Thanks,

    Xuan

  • Posted 15 July 2024, 8:37 am EST

    Hi Xuan,

    Updating the Web.config file treats ‘wwwroot’ folder as the start folder for the Web Application therefore you’ll need to visit ‘https://localhost:44328/index.html’ to get the Web Designer to load.

    Hope it helps!

    Regards,

    Anand

  • Posted 15 July 2024, 9:49 pm EST - Updated 15 July 2024, 9:55 pm EST

    Hi Anand,

    Maybe you misunderstood. I see the Web Designer works well. But my app doesn’t work anymore after I modify Routes (get error code 500).

    The flow of my app is : ‘login page’ → ‘home page’ → ‘report page’.

    In ‘report page’, I need to embed AR web designer into a layout. For example below:



    However, My app have broken after I modify the Routes. (Only AR web designer works).

    How can I fix that?

    Thanks,

    Xuan

  • Posted 16 July 2024, 6:56 am EST

    Hi Xuan,

    Unfortunately, the route

    routes.MapRoute(
    	name: "Default",
    	url: "{controller}/{action}/{id}",
    	defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
    

    prevents the JSViewer from accessing the reports from ‘/api/reports’, therefore, it is suggested to use the MVC’s

    MapMvcAttributeRoutes()
    method and define your application such that the Login page is within the ‘wwwroot’ folder of your project along with Home, and Report page.

    Thanks,

    Anand

  • Posted 16 July 2024, 10:17 pm EST

    Hi Anand,

    I can’t define my application into the ‘wwwroot’ folder because that has a lot of functions and pages. I don’t want to change all my application.

    I still want to keep this route

    routes.MapRoute(
    	name: "Default",
    	url: "{controller}/{action}/{id}",
    	defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );


    for my app to run normally and find ways to make AR designer work too.

    I don’t think changing my app is a good idea. (There are hundreds of functions in it)

    Is there any way to make my app work properly and AR designer also work?

    Thanks,

    Xuan

  • Posted 17 July 2024, 8:05 am EST

    Hi Xuan,

    You can add constraints to the MapRoute() function. See sample code below:

            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                    constraints: new { controller = "Home" } //Modify constraints as per need
                );
                routes.MapMvcAttributeRoutes();
    	}
    

    For more information, please refer to the following pages of the Microsoft documentation: Creating a Route Constraint (C#)

    I hope it helps!

    I have also attached the modified sample with both Controller routes and wwwroot path working.

    Updated.zip

  • Posted 17 July 2024, 11:38 pm EST - Updated 17 July 2024, 11:43 pm EST

    Hi Akshay,

    Thanks for your response.

    That’s a big step so far, both Controller routes and wwwroot path working well.

    But the home page (sample app you give me) can’t access js file and css file any more.



    And this error is also happen in my application.

    What should i do next?

  • Posted 18 July 2024, 2:06 am EST

    Hi Xuan,

    The CSS is not loaded because in the sample bootstrap files were removed and Bundle Config was removed.

    To fix this issue , you may first fix the BundleConfig.cs. see sample code:

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
               "~/Scripts/jquery-{version}.js"));
    
        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.unobtrusive*",
            "~/Scripts/jquery.validate*"));
    
        bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
            "~/Scripts/knockout-{version}.js",
            "~/Scripts/knockout.validation.js"));
    
        bundles.Add(new ScriptBundle("~/bundles/app").Include(
            "~/Scripts/sammy-{version}.js",
            "~/Scripts/app/common.js",
            "~/Scripts/app/app.datamodel.js",
            "~/Scripts/app/app.viewmodel.js",
            "~/Scripts/app/home.viewmodel.js",
            "~/Scripts/app/_run.js"));
    
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));
    
        bundles.Add(new Bundle("~/bundles/bootstrap").Include(
            "~/Scripts/bootstrap.js"));
    
        bundles.Add(new StyleBundle("~/Content/css").Include(
             "~/Content/bootstrap.css",
             "~/Content/Site.css"));
    }
    

    Now, we may add the required CSS and JS files to the route we used to add StaticFiles. This can be handled with two ways, you may use the approach which best suits your use case.

    Option 1:

    Add all files to wwwroot folder too as that is the only route we have exposed in the sample.

    Startup.cs:

            public void Configuration(IAppBuilder app)
            {
                app.UseReportDesigner(config => {
                    config.UseFileStore(ResourcesRootDirectory, null, FileStoreOptions.NestedFoldersLookup);
                });
                app.UseReportViewer(config => config.UseFileStore(ResourcesRootDirectory));
    
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileSystem = new PhysicalFileSystem("wwwroot"),
                    RequestPath = new PathString("")
                });
            }
    

    Option 2:

    Add another route for Static Files and only add files to project root folder

    Startup.cs

            public void Configuration(IAppBuilder app)
            {
                app.UseReportDesigner(config => {
                    config.UseFileStore(ResourcesRootDirectory, null, FileStoreOptions.NestedFoldersLookup);
                });
                app.UseReportViewer(config => config.UseFileStore(ResourcesRootDirectory));
    
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileSystem = new PhysicalFileSystem("wwwroot"),
                    RequestPath = new PathString("")
                });
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileSystem = new PhysicalFileSystem(""),
                    RequestPath = new PathString("")
                });
            }
    

    Please refer to the attached sample. In the attached sample, I am using the second approach so static files from both the folder routes are used.

    FixedBundlingIssue.zip

  • Posted 18 July 2024, 3:51 am EST

    Hi Akshay,

    I see active report call API has routes like “api/theme/list”, “api/reports/content”. Unfortunately, my application is also calling the api in this path, for example: api/reports/getlist, can you provide a way to edit the active report routes to something other than the existing one like ar/ {controller}/{action}?

    I just want your api to be different from the route I’m running, I think this will solve the problem I’m having here.

  • Posted 19 July 2024, 12:43 am EST

    Hi Xuan,

    This seems to be a separate query. Since the original issue is resolved, it is suggested to create a new case for a separate issue as it helps to manage and review cases better.

    Please create a new case on the support portal or the forum and we will get back to you one the new case asap.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels