Answered by:
ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel

Question
-
User-1602535186 posted
I have ASP.NET 3.0 Application, I am getting error as IHostBuilder does not contain definition of UseKestrel. Can I Use UseKestrel or ConfigureKestrel In ASP.NET 3.0 ?
Monday, March 23, 2020 2:17 PM
Answers
-
User-474980206 posted
.ConfigureWebHostDefaults(webBuilder => { // .UseKestrel() not needed because its the default webBuilder.ConfigureKestrel(options => { }); webBuilder.UseStartup<Startup>(); });
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 23, 2020 3:03 PM
All replies
-
User-474980206 posted
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureLogging(logging => { logging.ClearProviders(); logging.AddConsole(); }) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseKestrel(options => {} ); webBuilder.UseStartup<Startup>(); });
that is correct. UseKestrel() is an extension method for a IWebHostBuilder. use the ConfigeWebHostDefaults() extension method:Monday, March 23, 2020 2:36 PM -
User-1602535186 posted
Means I have to use, But how ConfigureKestrel As I have code .ConfigureKestrel((context, options) => { //Some Code }
ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
Monday, March 23, 2020 2:43 PM -
User-1602535186 posted
I am getting error as ''Cannot resolve scoped service from root provider.'' when using options.ApplicationServices.GetRequiredService<IServiceName>
Monday, March 23, 2020 3:02 PM -
User-474980206 posted
.ConfigureWebHostDefaults(webBuilder => { // .UseKestrel() not needed because its the default webBuilder.ConfigureKestrel(options => { }); webBuilder.UseStartup<Startup>(); });
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 23, 2020 3:03 PM -
User-1602535186 posted
Still the error persist
Monday, March 23, 2020 6:18 PM -
User711641945 posted
Hi TechAspirant,
> IHostBuilder does not contain definition of UseKestrel
IHostBuilder contains the definition of UseKestrel.
Reference:
You just share the part of program.cs.What is your whole program.cs and Startup.cs?Please share a simple demo which could reproduce the issue.Otherwise,we can't reproduce your issue and help you resolve it.
Best Regards,
Rena
Tuesday, March 24, 2020 3:04 AM