问题
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 ?
回答1:
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");
回答2:
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");
来源:https://stackoverflow.com/questions/59995626/asp-net-core-3-rotativa-startup-cs-env-problem