Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ihostingenvironment has been converted to IWebHostEnvironment in dot net core 3.1 #52

Open
abdoneemmsc opened this issue Feb 10, 2020 · 13 comments

Comments

@abdoneemmsc
Copy link

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

@WirwinRo
Copy link

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

@MrCodeB2
Copy link

MrCodeB2 commented Mar 3, 2020

Same problem here

@WirwinRo
Copy link

WirwinRo commented Mar 3, 2020

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

@jsoques
Copy link

jsoques commented Mar 23, 2020

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.

@MrCodeB2
Copy link

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

@WirwinRo
Copy link

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
Copy link

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

@MrCodeB2
Copy link

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 :-)

@jsoques
Copy link

jsoques commented Mar 26, 2020

#49

@ayazzali
Copy link

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
Copy link

@abdoneemmsc maybe close issue?

@KBlbym
Copy link

KBlbym commented Apr 16, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@KBlbym @jsoques @ayazzali @WirwinRo @MrCodeB2 @abdoneemmsc and others