Hosting on IIS
An ASP.NET Core application shouldn't be directly exposed to the internet, even if it's supported for Kestrel or HTTP.sys
. It would be best to have something such as a reverse proxy in between, or at least a service that watches the hosting process. For ASP.NET Core, IIS isn't just a reverse proxy. It also takes care of the hosting process, in case it breaks because of an error. If that happens, IIS will restart the process. Nginx may be used as a reverse proxy on Linux that also takes care of the hosting process.
Note
Be sure you created a new project or removed the Kestrel configuration of the previous section. This won't work with IIS.
To host an ASP.NET Core web on IIS or Azure, you need to publish it first. Publishing doesn't only compile the project; it also prepares the project for hosting on IIS, Azure, or a web server on Linux, such as Nginx.
The following command will publish the project:
dotnet publish -o ..\published...