MDrivenServerCore in IIS
No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Edited|July|12|2025}}
<message>Write the content here to display this box</message>
<message>Write the content here to display this box</message>
'''NOTE:''' These principles also work for MDrivenTurnkeyCore in IIS.
'''NOTE:''' These principles also work for MDrivenTurnkeyCore in IIS.
Line 13: Line 14:
# Change this line in the web.config  
# Change this line in the web.config  
  <aspNetCore processPath=".\AppCompleteGenericCore.exe" stdoutLogEnabled<nowiki/>="false<nowiki/>" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" '''arguments="-iis=<nowiki>https://localhost/mdrCore1</nowiki>"''' />  SET THE URL YOUR APP SHOULD USE
  <aspNetCore processPath=".\AppCompleteGenericCore.exe" stdoutLogEnabled<nowiki/>="false<nowiki/>" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" '''arguments="-iis=<nowiki>https://localhost/mdrCore1</nowiki>"''' />  SET THE URL YOUR APP SHOULD USE
'''or''' '''even better''', follow this instruction: [[Documentation:Injecting the Core server command line parameters via file|Injecting the Core server command line parameters via file]] and leave the web.config unchanged:
'''or''' '''even better''', follow this instruction: [[Documentation:Injecting the Core server command line parameters via file|Injecting the Core server command line parameters via file]] and leave the web.config unchanged.
 
If your app does not start:
 
# double check in IIS/Modules that AspNetCoreModuleV2  is listed, if not - the hosting bundle has not been installed.
# Run iisreset as admin
# set read/write to whole app folder to specific user of app-pool (or just everything to everyone to ensure no file access issues)
# check EventViewer for errors related to this
# check /logs for MDrivenServer and Turnkey
If you for some reason WANT to dabble with the web.config look below, but you should inject with file instead.


Complete web.config:
Complete web.config:
Line 34: Line 44:


==== Turnkey core in IIS ====
==== 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.
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 [[Documentation:MDrivenServerOverride|MDrivenServerOverride]].xml file in its App_Data so that your MDrivenServer may be found.


==== Both MDrivenServer Core, and TurnkeyServer Core ====
==== Both MDrivenServer Core, and TurnkeyServer Core ====
Line 41: Line 51:
This powershell script automatically install and update an IIS website.
This powershell script automatically install and update an IIS website.


[[PowerShell script for IIS installation]]
[[Documentation:PowerShell script for IIS installation|PowerShell script for IIS installation]]
===== Creating and deleting .net core sites using command line =====
===== 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)
Create app pool and site (parameter 1 is name of site and app-pool, parameter 2 is the site URL)

Latest revision as of 05:16, 29 January 2025

This page was created by Hans.karlsen@mdriven.net on 2023-10-16. Last edited by Stephanie@mdriven.net on 2025-01-29.


NOTE: These principles also work for MDrivenTurnkeyCore in IIS.

Microsoft articleS on installing .net core on IIS:

  1. https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-8.0&tabs=visual-studio
  2. https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-8.0

To host .net core in IIS:

  1. Install runtime for IIS, for example dotnet-hosting-7.0.15-win.exe. Please note that it should be version 7
  2. Create new AppPool (only 1 app per pool), set AppPooll to "No managed code"
  3. Extract zip of installation into your site folder
  4. 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.

If your app does not start:

  1. double check in IIS/Modules that AspNetCoreModuleV2 is listed, if not - the hosting bundle has not been installed.
  2. Run iisreset as admin
  3. set read/write to whole app folder to specific user of app-pool (or just everything to everyone to ensure no file access issues)
  4. check EventViewer for errors related to this
  5. check /logs for MDrivenServer and Turnkey

If you for some reason WANT to dabble with the web.config look below, but you should inject with file instead.

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"