I'm working on an ASP.NET Core application that I have upgraded from v2.2 to v3.1.
When I start the application using IIS Express without SSL enabled, I get this error in Google Chrome:
This site can't be reached. localhost refused to connect.
When I enable SSL, I get this error instead:
This localhost page can't be found. No web page was found for the web address: https://localhost:44367.
I have have an IIS website configured to the directory where my application sits. In the project settings, I can set the 'Launch' setting to 'IIS', but when I do this I also get the same error.
Screenshot of my web project settings: .
When I create a new blank ASP.NET Core 3.1 web project and run it with the same settings on IIS Express, it runs fine.
Based on suggestions elsewhere, I have tried the following:
I'm at a loss.
Here is my launchSettings.json file:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://myapplication.debug",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:54236",
"sslPort": 44367
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
When comparing with the launchSettings.json file of a fresh project I can't see any notable difference. Is there anything else that would cause this failure?
I should note that I did change the port number - it was initially at port number 50192, but when I attempt to run the website to that address (http://localhost:50192) it gives me a different error:
It appears I was missing something in my Program.cs when upgrading from aspnetcore 2.2 to 3.1.
Until now I had this:
return WebHost.CreateDefaultBuilder(args)
.ConfigureServices(services => services.AddAutofac())
.UseStartup<Startup>();
On looking at a fresh v3.1 project, it had something like this instead:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});