3

Im try to use Rotativa ım follow this guide in start.cs in configure function ım add this code

  RotativaConfiguration.Setup(env);
Severity    Code    Description Project File    Line    Suppression State
Error   CS1503  Argument 1: cannot convert from 'Microsoft.AspNetCore.Hosting.IWebHostEnvironment' to 'Microsoft.AspNetCore.Hosting.IHostingEnvironment'    

ım search this error and find this and convert my code like this

 RotativaConfiguration.Setup(env.WebRootPath, "Rotativa");

and its give me this error

Severity    Code    Description Project File    Line    Suppression State
Error   CS1503  Argument 1: cannot convert from 'string' to 'Microsoft.AspNetCore.Hosting.IHostingEnvironment'  

ım add Rotative folder in wwwroot and added wkhtmltoimage.exe, wkhtmltopdf.exe

my package version Rotativa.aspnetcore v1.1.1 ım using current asp.net core version 3.xx what is problem any one can be explain me ?

Mehmet Başaran
  • 77
  • 2
  • 10

3 Answers3

17

Remove existing Rotativa.AspNetCore from Nuget packages then install the beta version:

Install-Package Rotativa.AspNetCore -Version 1.2.0-beta

This has the overload method in it that also works with IWebHostingEnvironment

After installing configure in Configure method as:

RotativaConfiguration.Setup(env.WebRootPath, "Rotativa");
Waqar UlHaq
  • 6,144
  • 2
  • 34
  • 42
Edi
  • 1,900
  • 18
  • 27
0

Im find a solution like this in statup.cs in configure function add env2 and obsolute

        [Obsolete]
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.AspNetCore.Hosting.IHostingEnvironment env2)

and change this like

   RotativaConfiguration.Setup(env2);

its working now but ıts bad solution if you know better one pls describe it.

Works on versions 3.0 and 3.1

// Rotary configuration 
// This is for the rotating to use the files in the Rotating folder
RotativaConfiguration.Setup (env.ContentRootPath, "Rotativa");
Mehmet Başaran
  • 77
  • 2
  • 10
0

install Install-Package Rotativa.AspNetCore -Version 1.2.0-beta

set Rotativa environment variable to RotativaConfiguration.Setup(env.WebRootPath, "/usr/bin/");

If you are on Ubuntu 20.10 or 20.04 install wkhtmlpdf. sudo apt install wkhtmlpdf

This works for Dot Net Core 3.1 or 5.0 I have tested both.