Search code examples
asp.net-core-3.0rotativaasp.net-core-3.1

asp.net core 3 rotativa startup.cs env problem


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 ?


Solution

  • 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");