I have written an ASP.NET application that is based on .NET core 1.1. This application works as expected. Today, I just upgraded my server to dotnet-sdk-2.0.0-preview2-006497
and made necessary changes in the .csproj
file.
In my application's main method, I have the following code:
var host = new WebHostBuilder()
.UseKestrel(options => {
options.UseHttps("MyCert.pfx");
})
...
This code used to work fine under .net core 1.0 but gives an error under .net core 2.0.
KestrelServerOptions does not contain a definition for UseHttps and
the best extension method overload
ListenOptionsHttpsExtensions.UseHttps(ListenOptions, string) requires
a receiver of type ListenOptions
I am wondering how I can fix this. Can I just pass null
as a parameter? Regards.
You can set the Kestrel ports inside the appsettings. json file. A simple block of JSON does it. You might notice that there is an appsettings.Development.
Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included by default in ASP.NET Core project templates. Kestrel supports the following scenarios: HTTPS. Opaque upgrade used to enable WebSockets.
Fast: ASP.NET Core no longer depends on System. Web. dll for browser-server communication. ASP.NET Core allows us to include packages that we need for our application.
In the case of the Kestrel web server, the process name that is used to host and run the ASP.NET Core application is the project name. As of now, we are using visual studio to run the ASP.NET Core application. By default, the visual studio uses IIS Express to host and run the ASP.NET Core application.
This is a breaking change, see this announcement, the important bit being:
There is no overload on .Listen() that allows you to configure an SSL cert without using an options lambda.
In other words you can only add HTTPS within or with some listen options. The simplest alternative would be:
var host = new WebHostBuilder()
.UseKestrel(options =>
options.Listen(IPAddress.Any, 443, listenOptions =>
listenOptions.UseHttps("MyCert.pfx")))
...
So you're saying listen on any assigned IP using port 443.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With