question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IHostBuilder not working while IWebHostBuilder in Linux in aspnet core 3.1 web api application

See original GitHub issue

I have .net core web api project. I am running my application in both Windows and Linux

Problem is My application get starts and works in both linux and windows with IWebHostBuilder while equivalent(what i think so) code for using IHostBuilder didn’t start my application in linux.

Please somebody give idea what wrong i am doing

Following currently works

   public static IWebHostBuilder BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args).
           ConfigureKestrel(serverOptions =>
           {
           }).UseIISIntegration()
           .UseStartup<StartupShutdownHandler>(); 

Following doesn’t works in linux but works in windows

 public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)        
        .ConfigureWebHostDefaults(webBuilder => webBuilder.UseKestrel().UseIIS().UseStartup<StartupShutdownHandler>());

I have to run my app on both windows and linux

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Tratchercommented, Apr 13, 2020

“server.urls” is considered obsolete and replaced by “urls”. We transitioned to “urls” quite a while ago, but I don’t see the associated annoucement. WebHost checked both for backcompat. https://github.com/dotnet/aspnetcore/blob/d4a2fa1ceb3b9c10054da8a7c6a4bd61801aea18/src/Hosting/Hosting/src/Internal/WebHost.cs#L303 GenericHost does not. https://github.com/dotnet/aspnetcore/blob/e3d3da3546aa2085aa39520f3c302d0672e5bab8/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs#L71

0reactions
KamranShahidcommented, Apr 13, 2020

“server.urls” is considered obsolete and replaced by “urls”. We transitioned to “urls” quite a while ago, but I don’t see the associated annoucement. WebHost checked both for backcompat. https://github.com/dotnet/aspnetcore/blob/d4a2fa1ceb3b9c10054da8a7c6a4bd61801aea18/src/Hosting/Hosting/src/Internal/WebHost.cs#L303

GenericHost does not. https://github.com/dotnet/aspnetcore/blob/e3d3da3546aa2085aa39520f3c302d0672e5bab8/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs#L71

Your are correct. looks like we were using some initial way assigning service which isn’t available even in documents. I will try to update this in my service. Any way thanks for this precious information. Will try to edit my service file tomorrow and run it

Read more comments on GitHub >

github_iconTop Results From Across the Web

IHostBuilder not working while IWebHostBuilder in Linux in ...
Problem is My application get starts and works in both linux and windows with IWebHostBuilder while equivalent(what i think so) code for using ......
Read more >
ASP.NET Core Web Host
The host is responsible for app startup and lifetime management. At a minimum, the host configures a server and a request processing pipeline....
Read more >
NET Generic Host in ASP.NET Core
Use .NET Core Generic Host in ASP.NET Core apps. Generic Host is responsible for app startup and lifetime management.
Read more >
NET Core 2.2 -> 3.1 API - App Builds but stuck loading
I am, I did just find that I was using IWebHostBuilder in my Program.cs, while a new project uses IHostBuilder, by updating this...
Read more >
5 ways to set the URLs for an ASP.NET Core app
In this post I describe 5 different ways to set which URLs your ASP.NET Core application listens on.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found