Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i trying to make a reports in mvc core
i want to return the view as pdf



Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'Microsoft.AspNetCore.Hosting.IWebHostEnvironment' to 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' ExaminationSystem D:\ITI\MVC\Project\ExaminationSystem\ExaminationSystem\Startup.cs 78 Active

What I have tried:

i tried to cast but still cannot cast it
Posted
Updated 15-Jan-20 19:07pm
Comments
Richard Deeming 13-Dec-19 10:55am    
There's a secret error in your secret code. You'll need to fix that error.

At a guess, you're mixing constructs from .NET Core 2.x and .NET Core 3. You can't simply cast an IWebHostEnvironment[^] to an IHostingEnvironment[^], or vice-versa.

1 solution

In ASP.NET Core 3 use following for Rotativa configuration:
RotativaConfiguration.Setup(env.WebRootPath, "Rotativa");
Add a new folder inside "wwwroot" with name “Rotativa” and inside this folder keep the wkhtmltoimage.exe and wkhtmltopdf.exe files.
 
Share this answer
 
Comments
t.alkahtiri 19-Jan-20 13:39pm    
Thank you very much, you make my day
g00n3r11 26-Mar-20 10:36am    
Compiler complains that string cannot to convert to IHostingEnvironment. Is there an updated version that takes those 2 string parameters?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900