.NETASP.NETIIS8 min read

Install .NET and host ASP.NET applications

Install .NET Runtime and deploy ASP.NET Core applications on IIS or Kestrel.


.NET is Microsoft's platform for web applications, APIs, and services. You can host with IIS or directly with Kestrel.

Step 1 — Install .NET Runtime

powershell
# Download the installer script
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1"

# Install ASP.NET Core Runtime
.\dotnet-install.ps1 -Channel 8.0 -Runtime aspnetcore -InstallDir "C:\Program Files\dotnet"

# Install full .NET Runtime
.\dotnet-install.ps1 -Channel 8.0 -InstallDir "C:\Program Files\dotnet"

Or download the installer from https://dotnet.microsoft.com/download

Step 2 — Verify installation

powershell
dotnet --info
dotnet --list-runtimes

Step 3 — Install ASP.NET Core module for IIS

Download and install the Hosting Bundle:

powershell
# Download Hosting Bundle
Invoke-WebRequest -Uri "https://download.visualstudio.microsoft.com/download/pr/hosting-bundle-8.0.x.exe" -OutFile "hosting-bundle.exe"
.\hosting-bundle.exe /install /quiet /norestart

# Restart IIS
iisreset

Step 4 — Deploy application on IIS

Publish your app locally:

powershell
dotnet publish -c Release -o C:\inetpub\myapp

Create the site in IIS:

powershell
New-IISSite -Name "MyApp" -PhysicalPath "C:\inetpub\myapp" -BindingInformation "*:80:myapp.mydomain.com"

Configure the Application Pool to No Managed Code:

powershell
Set-ItemProperty "IIS:\AppPools\MyApp" -Name "managedRuntimeVersion" -Value ""

Step 5 — Host with Kestrel (without IIS)

Create a Windows service:

powershell
sc.exe create MyAppService binPath= "C:\apps\myapp\myapp.exe --urls=http://0.0.0.0:5000" start= auto
sc.exe start MyAppService

Step 6 — Configure as service with NSSM

powershell
# Download NSSM
Invoke-WebRequest -Uri "https://nssm.cc/release/nssm-2.24.zip" -OutFile nssm.zip
Expand-Archive nssm.zip -DestinationPath C:\tools

# Install service
C:\tools\nssm-2.24\win64\nssm.exe install MyApp "C:\apps\myapp\myapp.exe"
C:\tools\nssm-2.24\win64\nssm.exe set MyApp AppDirectory "C:\apps\myapp"
C:\tools\nssm-2.24\win64\nssm.exe start MyApp

Step 7 — Environment variables

powershell
[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Production", "Machine")
[Environment]::SetEnvironmentVariable("ConnectionStrings__Default", "Server=localhost;Database=myapp;...", "Machine")

Your Baires Host Windows VPS is ideal for hosting .NET applications with dedicated performance.


Was this guide helpful?