Internet Information Services (IIS) is a web server developed by Microsoft. Deploying your ASP.NET Core application to IIS allows you to host it on a Windows server for public or private access.
Deploying to IIS is ideal for hosting internal business applications or public-facing websites in a Windows environment.
Follow these steps:
// Download and install the hosting bundle from:
// https://dotnet.microsoft.com/en-us/download/dotnet
The hosting bundle includes the ASP.NET Core Module, which allows IIS to work with Kestrel.
// Run the following command in the terminal:
dotnet publish -c Release -o ./publish
This generates a folder with the compiled files needed for deployment in the publish
directory.
inetmgr
).
Physical Path: C:\Path\To\Publish\Folder
Port: 5000
// Access your application in the browser:
http://localhost:5000
Ensure that the application runs correctly and check the IIS logs for any errors.
// Add or update the Web.config file in your published folder
<configuration>
<system.webServer>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
This ensures IIS knows how to start your application.