Rotativa.AspNetCore icon indicating copy to clipboard operation
Rotativa.AspNetCore copied to clipboard

.Net Core 3.0 Compatibility

Open tstraus13 opened this issue 5 years ago • 9 comments

Hello,

I just wanted to inform that in .Net Core 3.0 the IHostingEnvironment has changed to IWebHostEnvironment. So when trying to configure rotativa with RotativaConfiguration.Setup(env) it throws an error about converting between the types. I was able to temporarily remedy the issue by casting the env variable to IHostingEnvironment, like so RotativaConfiguration.Setup((Microsoft.AspNetCore.Hosting.IHostingEnvironment)env), but it warns that the type is obsolete. Thanks.

tstraus13 avatar Nov 06 '19 21:11 tstraus13

I had to install the pre-release package and the overload was there.

lehne avatar Nov 15 '19 00:11 lehne

any solution to this?

comfreakph avatar Nov 27 '19 14:11 comfreakph

any solution to this?

Just use the overload,

Install the pre-release by putting Install-Package Rotativa.AspNetCore -Version 1.2.0-beta in to either the console in visual code or the package manager console in visual studio.

RotativaConfiguration.Setup(env.ContentRootPath, "wwwroot/Rotativa"); Then make a folder in wwwroot call it Rotativa and put wkhtmltopdf.exe and wkhtmltoimage.exe inside it.

killerfrienddk avatar Dec 12 '19 10:12 killerfrienddk

After upgrading to .net core 3.1, and Rotativa 1.2.0-beta, I'm getting the following error on the published version of my app: Unable to find view '[ViewName]'. The following locations were searched: ... [List of relative paths being searched]

This is when calling the ViewAsPdf function.

I can see that the view is present at the location that it says is being searched. Is it possible to see the absolute path of the search location? I'm struggling to see why its not picking up the view.

Edit:

I posted too soon; fixed it by adding the Razor runtime package (Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation) and adding it to Startup:

services.AddRazorPages().AddRazorRuntimeCompilation(); (added to ConfigureService)

cjnaude avatar Jan 24 '20 09:01 cjnaude

Thanks for the information, it helped me to correct this error that was happening to me too.

silvairsoares avatar Jan 30 '20 13:01 silvairsoares

@tstraus13 maybe close issue?

ayazzali avatar Mar 29 '20 12:03 ayazzali

Has this fix been released?

tstraus13 avatar Mar 30 '20 10:03 tstraus13

Current mitigation: install wkhtmltopdf sudo apt update && sudo apt upgrade sudo apt install wkhtmltopdf

The default wkhtmltopdf package in Ubuntu 20.10 works with rotativa 1.2.0 beta. set env variable in Startup.cs to: RotativaConfiguration.Setup(env.WebRootPath, "/usr/bin/");

This works on Ubuntu 20.10 and most likely 20.04. It works with dotnet 5.0 and dotnet 3.1.

ne0rrmatrix avatar Mar 20 '21 11:03 ne0rrmatrix

Hi! When I try this RotativaConfiguration.Setup(env.WebRootPath, "/usr/bin/");

I get : canot be null

Can you helpme please?

SilAlvarez avatar Jul 13 '22 21:07 SilAlvarez