I have this code running kestrel
builder.WebHost.UseKestrel().UseUrls("https://myfirstproj1.asp")
.UseIISIntegration();
but I can’t access the site through the url I specified. What am I doing wrong?
I have this code running kestrel
builder.WebHost.UseKestrel().UseUrls("https://myfirstproj1.asp")
.UseIISIntegration();
but I can’t access the site through the url I specified. What am I doing wrong?
3
Answers
.net 6 does not use UserUrls() method any more.
This is how to do it on .net 6.
On Program.cs
UseKestrel also works for me. No idea what the difference is :/
As of .NET 7 you now need to do this as the above no longer worked for me on .NET 7 projects (although works on .NET 6 projects.
Open appsettings.json and add the following:
You can specify an endpoint for Https here too but I only needed to set an http port as it is proxied from Apache on a Linux server.
Note that if you add an https option here too and do not have a certificate configured then the site will still preview but will fail to load on the Kestrel server on Ubuntu.
It would appear the above option works on .NET 6 too and it seems simpler as enables the URL and port to be set using the settings file in the same way as other configuration options as opposed to changing the code.