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

ihostingenvironment has been converted to IWebHostEnvironment in dot net core 3.1

Open abdoneemmsc opened this issue 5 years ago • 13 comments

ihostingenvironment has been converted to IWebHostEnvironment in dot net core 3.1 so RotativaConfiguration.Setup(env) not working

abdoneemmsc avatar Feb 10 '20 05:02 abdoneemmsc

Yea if there's some way to do work, please tell us how to do thanks

WirwinRo avatar Feb 12 '20 12:02 WirwinRo

Same problem here

MrCodeB2 avatar Mar 03 '20 09:03 MrCodeB2

what I see they haven't made the version for 3.x yet :( I'm sorry because you see that the tool is very good

WirwinRo avatar Mar 03 '20 09:03 WirwinRo

Until the new version comes out for IWebHostEnvironment, I am casting it it IHostingEnvironment. Seem to work. Hopefully this will be temporary.

So in Startup.cs where you do: RotativaConfiguration.Setup(env, "...."); replace with: RotativaConfiguration.Setup((Microsoft.AspNetCore.Hosting.IHostingEnvironment)env, "....");
VS will complain it's Obsolete, so just add [Obsolete] attribute to Startup function.

jsoques avatar Mar 23 '20 18:03 jsoques

What worked for me was this from ReadMe.md:

Basic configuration done in Startup.cs:

RotativaConfiguration.Setup(env);

or, if using Asp.net Core 3.0:

RotativaConfiguration.Setup("<root path here>", "path/relative/to/root");

Make sure you have a folder with the wkhtmltopdf.exe file accessible by the process running the web app. By default it searches in a folder named "Rotativa" in the root of the web app. If you need to change that use the optional parameter to the Setup call RotativaConfiguration.Setup(env, "path/relative/to/root")

So i changed my code in Setup.cs to: RotativaConfiguration.Setup(env.ContentRootPath, "wwwroot/Rotativa"); -> this worked

MrCodeB2 avatar Mar 24 '20 07:03 MrCodeB2

Until the new version comes out for IWebHostEnvironment, I am casting it it IHostingEnvironment. Seem to work. Hopefully this will be temporary.

So in Startup.cs where you do: RotativaConfiguration.Setup(env, "...."); replace with: RotativaConfiguration.Setup((Microsoft.AspNetCore.Hosting.IHostingEnvironment)env, "...."); VS will complain it's Obsolete, so just add [Obsolete] attribute to Startup function.

Thanks Jsoques this work perfectly

WirwinRo avatar Mar 24 '20 20:03 WirwinRo

What worked for me was this from ReadMe.md:

Basic configuration done in Startup.cs: RotativaConfiguration.Setup(env); or, if using Asp.net Core 3.0: RotativaConfiguration.Setup("<root path here>", "path/relative/to/root"); Make sure you have a folder with the wkhtmltopdf.exe file accessible by the process running the web app. By default it searches in a folder named "Rotativa" in the root of the web app. If you need to change that use the optional parameter to the Setup call RotativaConfiguration.Setup(env, "path/relative/to/root")

So i changed my code in Setup.cs to: RotativaConfiguration.Setup(env.ContentRootPath, "wwwroot/Rotativa"); -> this worked

Hi MrCodeB2 well I'm using asp core 3.1 and don't work this way, but thanks by share maybe someone uses 3.0, this works

WirwinRo avatar Mar 24 '20 20:03 WirwinRo

What worked for me was this from ReadMe.md:

Basic configuration done in Startup.cs: RotativaConfiguration.Setup(env); or, if using Asp.net Core 3.0: RotativaConfiguration.Setup("<root path here>", "path/relative/to/root"); Make sure you have a folder with the wkhtmltopdf.exe file accessible by the process running the web app. By default it searches in a folder named "Rotativa" in the root of the web app. If you need to change that use the optional parameter to the Setup call RotativaConfiguration.Setup(env, "path/relative/to/root")

So i changed my code in Setup.cs to: RotativaConfiguration.Setup(env.ContentRootPath, "wwwroot/Rotativa"); -> this worked

Hi MrCodeB2 well I'm using asp core 3.1 and don't work this way, but thanks by share maybe someone uses 3.0, this works

<TargetFramework>netcoreapp3.1</TargetFramework> I am using 3.1 also and its working :-)

MrCodeB2 avatar Mar 25 '20 06:03 MrCodeB2

https://github.com/webgio/Rotativa.AspNetCore/issues/49

jsoques avatar Mar 26 '20 17:03 jsoques

What worked for me was this from ReadMe.md:

Basic configuration done in Startup.cs: RotativaConfiguration.Setup(env); or, if using Asp.net Core 3.0: RotativaConfiguration.Setup("<root path here>", "path/relative/to/root"); Make sure you have a folder with the wkhtmltopdf.exe file accessible by the process running the web app. By default it searches in a folder named "Rotativa" in the root of the web app. If you need to change that use the optional parameter to the Setup call RotativaConfiguration.Setup(env, "path/relative/to/root")

So i changed my code in Setup.cs to: RotativaConfiguration.Setup(env.ContentRootPath, "wwwroot/Rotativa"); -> this worked

Hi MrCodeB2 well I'm using asp core 3.1 and don't work this way, but thanks by share maybe someone uses 3.0, this works

there is a beta in nuget. and its working

<PackageReference Include="Rotativa.AspNetCore" Version="1.2.0-beta" />

ayazzali avatar Mar 29 '20 12:03 ayazzali

@abdoneemmsc maybe close issue?

ayazzali avatar Mar 29 '20 12:03 ayazzali

env.ContentRootPath

This doen't work because Setup method waiting for IHostingEnvironment parameter and you are passing a string, this causses problem.

I think the solution is updating de method to use IWebHostEnvironment. I am not sure.

KBlbym avatar Apr 16 '20 18:04 KBlbym