Can I use Reports on .NET CORE 3.1?

4 posts, 0 answers
  1. robert
    robert avatar
    1 posts
    Member since:
    Jan 2020

    Posted 11 Jan Link to this post

    with `<TargetFramework>netcoreapp3.1</TargetFramework>`?
  2. Neli
    Admin
    Neli avatar
    252 posts

    Posted 13 Jan Link to this post

    Hi Robert,

    Basically, you can follow the steps given in How To: Use HTML5 Report Viewer in an ASP.NET Core 3+ application article. Note that due to some changes between .NET CORE 3 and .NET CORE 3.1, there is a little difference in step2 in Setting up the ConfigurationService in the Startup.cs file. The code has to look as follows:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        this.services.AddTransient(ctx => new Controllers.ReportsController(new ConfigurationService(env)));
    
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }
    
        app.UseHttpsRedirection();
        app.UseDefaultFiles();
        app.UseStaticFiles();
    
        app.UseRouting();
        app.UseCors("MyPolicy");
    
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers().RequireCors("MyPolicy");
        });
    }

    In the attached file you can find a sample project. Before starting the application you might need to run the Upgrade Wizard.

     

    Regards,
    Neli
    Progress Telerik

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Vincent
    Vincent avatar
    53 posts
    Member since:
    Dec 2013

    Posted 3 days and 19 hours ago Link to this post

    I get  the error as follow:

    Cannot access the Reporting REST service. (serviceUrl = '../api/reports/'). Make sure the service address is correct and enable CORS if needed. (https://enable-cors.org)

  4. Neli
    Admin
    Neli avatar
    252 posts

    Posted 2 hours ago Link to this post

    Hello Vincent,

    This error indicates that the Telerik Reporting REST Service is not working properly.  Note that since R1 2020, we add dependency injection to the Web API controllers in .NET Core, so now the Reports Controller looks as follows:

    [Route("api/reports")]
    public class ReportsController : ReportsControllerBase
    {
        public ReportsController(IReportServiceConfiguration reportServiceConfiguration)
            : base(reportServiceConfiguration)
        {
        }
    
        protected override HttpStatusCode SendMailMessage(MailMessage mailMessage)
        {
            throw new System.NotImplementedException("This method should be implemented in order to send mail messages");
    
            // using (var smtpClient = new SmtpClient("smtp01.mycompany.com", 25))
            // {
            //    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            //    smtpClient.EnableSsl = false;
    
            // smtpClient.Send(mailMessage);
            // }
            // return HttpStatusCode.OK;
        }
    }
    
    Further information about the error can be found in Cannot access the Reporting REST service. (serviceUrl = '/api/reports'). Make sure the service address is correct and enable CORS if needed. (https://enable-cors.org) KB article.


    Regards,
    Neli
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top