NOTE: These principles also work for MDrivenTurnkeyCore in IIS.
Microsoft articleS on installing .net core on IIS:
- https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-8.0&tabs=visual-studio
- https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-8.0
To host .net core in IIS:
- Install runtime for IIS, for example dotnet-hosting-7.0.15-win.exe. Please note that it should be version 7
- Create new AppPool (only 1 app per pool), set AppPooll to "No managed code"
- Extract zip of installation into your site folder
- Change this line in the web.config
<aspNetCore processPath=".\AppCompleteGenericCore.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" arguments="-iis=https://localhost/mdrCore1" /> SET THE URL YOUR APP SHOULD USE
or even better, follow this instruction: Injecting the Core server command line parameters via file and leave the web.config unchanged:
Complete web.config:
<?xml version="1.0" encoding="utf-8"?> <configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath=".\AppCompleteGenericCore.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" arguments="-iis=https://localhost/MDRDebug" /> </system.webServer> </location> </configuration> <!--ProjectGuid: 3F248237-FF1B-4F4B-9029-DB6440643978-->
When you want to debug from VS - set argument -iis=https://localhost/mdrcore1/ or the name you have, stop AppPool, compile, then start AppPool and app - navigate via browser.
Turnkey core in IIS
The Turnkey core can also be hosted in IIS. In its Web.config, point out its target URL just like for MDrivenServer Core. Also, add an MDrivenServerOverride.xml file in its App_Data so that your MDrivenServer may be found.
Both MDrivenServer Core, and TurnkeyServer Core
See also: Injecting the Core server command line parameters via file
Creating and deleting .net core sites using PowerShell
This powershell script automatically install and update an IIS website.
PowerShell script for IIS installation
Creating and deleting .net core sites using command line
Create app pool and site (parameter 1 is name of site and app-pool, parameter 2 is the site URL)
mkdir "C:\inetpub\%1" %windir%\system32\inetsrv\appcmd add apppool /name:"%1" /managedRuntimeVersion:"" /managedPipelineMode:"Integrated" %windir%\system32\inetsrv\appcmd add site /name:"%1" /physicalPath:"C:\inetpub\%1" /bindings:https/*:443:%2 %windir%\system32\inetsrv\appcmd set app "%1/" /applicationPool:"%1"
Delete app pool and site
%windir%\system32\inetsrv\appcmd delete site "%1" %windir%\system32\inetsrv\appcmd delete apppool "%1" rmdir "C:\inetpub\%1"