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

Ocelot IHostBuilder and IWebHostBuilder issues #1047

Closed
gurelsoycaner opened this issue Oct 30, 2019 · 4 comments
Closed

Ocelot IHostBuilder and IWebHostBuilder issues #1047

gurelsoycaner opened this issue Oct 30, 2019 · 4 comments
Assignees
Labels
question Initially seen a question could become a new feature or bug or closed ;) waiting Waiting for answer to question or feedback from issue raiser

Comments

@gurelsoycaner
Copy link

gurelsoycaner commented Oct 30, 2019

Expected Behavior / New Feature

Hi,

I'm having this issue after updating my system to .Net Core 3.0

image

I need to dynamically create ocelot.json base on my environment but I'm getting this error
"cannot convert from Microsoft.Extension.Hosting.IHostEnvironment to Microsoft.AspNetCore.Host.IWebHostEnvironment"

I find out that ocelot is still using IWebHostBuilder which is for .Net core 2.x instead of IHostBuilder that comes with .Net cor 3.0.

Thanks in advance

@gurelsoycaner gurelsoycaner changed the title hi Ocelot IHostBuilder and IWebHostBuilder issues Oct 30, 2019
@catcherwong
Copy link
Contributor

You can use ConfigureWebHostDefaults to do that.

Here is a sample that you can take a look.

public static IHostBuilder CreateHostBuilder(string[] args) =>
              Host.CreateDefaultBuilder(args)
                 .ConfigureWebHostDefaults(webBuilder =>
                 {
                     webBuilder.UseUrls("http://*:9000")
                       .ConfigureAppConfiguration((hostingContext, config) =>
                       {
                           config
                               .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
                               .AddJsonFile("ocelot.json")
                               .AddEnvironmentVariables();

                           config.AddOcelot("your folder", hostingContext.HostingEnvironment);

                       })
                      .ConfigureServices(services =>
                      {
                          services.AddOcelot();
                      })
                     .Configure(app =>
                     {
                         app.UseOcelot().Wait();
                     });
                 });            

@gurelsoycaner
Copy link
Author

You can use ConfigureWebHostDefaults to do that.

Here is a sample that you can take a look.

public static IHostBuilder CreateHostBuilder(string[] args) =>
              Host.CreateDefaultBuilder(args)
                 .ConfigureWebHostDefaults(webBuilder =>
                 {
                     webBuilder.UseUrls("http://*:9000")
                       .ConfigureAppConfiguration((hostingContext, config) =>
                       {
                           config
                               .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
                               .AddJsonFile("ocelot.json")
                               .AddEnvironmentVariables();

                           config.AddOcelot("your folder", hostingContext.HostingEnvironment);

                       })
                      .ConfigureServices(services =>
                      {
                          services.AddOcelot();
                      })
                     .Configure(app =>
                     {
                         app.UseOcelot().Wait();
                     });
                 });            

Thanks, you've saved my day.

@raman-m
Copy link
Member

raman-m commented Sep 21, 2023

@gurelsoycaner Can we close the issue?

@raman-m raman-m self-assigned this Sep 21, 2023
@raman-m raman-m added question Initially seen a question could become a new feature or bug or closed ;) waiting Waiting for answer to question or feedback from issue raiser labels Sep 21, 2023
@raman-m
Copy link
Member

raman-m commented Jun 15, 2024

I'm having this issue after updating my system to .Net Core 3.0

.NET Core 3 is not supported

Outdated issue ❗

@raman-m raman-m closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Initially seen a question could become a new feature or bug or closed ;) waiting Waiting for answer to question or feedback from issue raiser
Projects
None yet
Development

No branches or pull requests

3 participants