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 ?
.ConfigureWebHostDefaults(webBuilder =>
{
// .UseKestrel() not needed because its the default
webBuilder.ConfigureKestrel(options => {
});
webBuilder.UseStartup<Startup>();
});
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
10 Points
38 Posts
ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 23, 2020 02:17 PM|TechAspirant|LINK
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 ?
All-Star
57864 Points
15491 Posts
Re: ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 23, 2020 02:36 PM|bruce (sqlwork.com)|LINK
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:
Member
10 Points
38 Posts
Re: ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 23, 2020 02:43 PM|TechAspirant|LINK
Means I have to use, But how ConfigureKestrel As I have code .ConfigureKestrel((context, options) => { //Some Code }
Member
10 Points
38 Posts
Re: ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 23, 2020 03:02 PM|TechAspirant|LINK
I am getting error as ''Cannot resolve scoped service from root provider.'' when using options.ApplicationServices.GetRequiredService<IServiceName>
All-Star
57864 Points
15491 Posts
Re: ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 23, 2020 03:03 PM|bruce (sqlwork.com)|LINK
Member
10 Points
38 Posts
Re: ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 23, 2020 06:18 PM|TechAspirant|LINK
Still the error persist
Contributor
2680 Points
874 Posts
Re: ASP.NET 3.0 IhostBuilder does not contain definition of UserKestrel
Mar 24, 2020 03:04 AM|Rena Ni|LINK
Hi TechAspirant,
> IHostBuilder does not contain definition of UseKestrel
IHostBuilder contains the definition of UseKestrel.
Reference:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1#kestrel-in-aspnet-core-apps
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