Share via


Nano Server: Deploying ASP.NET 5 site on Internet Information Services (IIS) Web Server

1. Introduction

In this article, we will demonstrate deploying ASP.NET 5 capabilities to Internet Information Services (IIS) on a Windows Server 2016 Technical Preview 4 Nano Server and allowing Nano Server to host ASP.NET 5 application.

↑ Return to Top

2. ASP.NET 5 with Web Server (IIS) on Nano Server Requirements

You will need the followings to host ASP.NET 5 application on Nano Server;

  • Microsoft-NanoServer-IIS-Package
  • Microsoft-OneCore-ReverseForwarders-Package (Not required since Windows Server 2016 GA/RTM)
  • httpPlatformHandler v1.2 x64

↑ Return to Top

3. Getting Started with ASP.NET 5 with Web Server (IIS) on Nano Server

In order to publish an ASP.NET 5 application, we will require the Nano Server to have Internet Information Services (IIS) capability and you can refer to the following article below;

↑ Return to Top

3.1. Deploying a new Nano Server with ReverseForwarder and Web Server (IIS) packages

For those who want to start a fresh Nano Server, the PowerShell example in creating a Nano Server with the basic package requirements below:

# Import New-NanoServerImage PowerShell Module for Technical Preview 4

Import-Module `

    -Global C:\NanoServer\NanoServerImageGenerator.psm1 ;

# Create New Basic NanoServer Image with IIS for Technical Preview 4 with IIS and ReverseForwarders Package

New-NanoServerImage `

    -MediaPath "Z:" `

    -BasePath "C:\NanoServer\Base" `

    -TargetPath "C:\NanoServer\WS16TP4NSIIS1\WS16TP4NSIIS1.vhd" `

    -EnableRemoteManagementPort `

    -Language "en-us" `

    -GuestDrivers `

    -DriversPath "C:\NanoServer\VMware-Drivers" `

    -Packages "Microsoft-NanoServer-IIS-Package, Microsoft-OneCore-ReverseForwarders-Package" `

    -Ipv4Address "192.168.100.25" `

    -Ipv4SubnetMask "255.255.255.0" `

    -Ipv4Gateway "192.168.100.3" `

    -DomainBlobPath "C:\NanoServer\WS16TP4NSIIS1.djoin" `

    -AdministratorPassword (ConvertTo-SecureString -String "Password" -AsPlainText -Force) ;

↑ Return to Top

3.2. Deploying ReverseForwarders package for Web Server (IIS) on existing Nano Server

If you already have an existing Nano Server with Internet Information Services (IIS) package but are missing the ReverseForwarders package, you can follow the example starting from here below:

# Establish a remote PowerShell Session to the Nano Server

Enter-PSSession `

    -ComputerName 192.168.100.24 `

    -Credential (New-Object `

        -TypeName System.Management.Automation.PSCredential `

        -ArgumentList "192.168.100.24\Administrator", `

        (ConvertTo-SecureString `

            -String "Password" `

            -AsPlainText `

            -Force) `

    ) ;

↑ Return to Top

3.2.1. Create the Packages folder to contain the ReverseForwarder Packages

Firstly, we will need to create the Packages folder structure to contain the CAB files.

# Create a Packages folder in Nano Server

New-Item `

    -Path "C:\Packages" `

    -Type directory ;

# Create an en-us language folder for Packages folder in Nano Server

New-Item `

    -Path "C:\Packages\en-us" `

    -Type directory ;

Now, we need to exit the current PSSession from your remote Nano Server so that we can copy the CAB files from your mounted Windows Server 2016 Technical Preview 4 ISO image on the management server.

# Exit PowerShell Session

Exit-PSSession ;

Verify you have the PowerShell version 5 on your management server so that you will have the new capability for Copy-Item to copy files using UNC path to the remote Nano Server.

# Show PowerShell version for Copy-Item

$PSVersionTable ;

↑ Return to Top

3.2.2. Copy the Packages from Management Server to Nano Server remotely

With PowerShell version 5, you will be able to using Copy-Item cmdlet to copy the files from your management server to the remote Nano Server using UNC path. You will need to ensure that your remote Nano Server firewall is enabled to allow File and Printer Sharing.

# Copy ReverseForwarders Package from DVD to Nano Server remotely

Copy-Item `

    -Path "D:\NanoServer\Packages\Microsoft-OneCore-ReverseForwarders-Package.cab" `

    -Destination "\192.168.100.24\C$\Packages" ;

# Copy ReverseForwarders Package from DVD to Nano Server remotely

Copy-Item `

    -Path "D:\NanoServer\Packages\en-us\Microsoft-OneCore-ReverseForwarders-Package.cab" `

    -Destination "\192.168.100.24\C$\Packages\en-us" ;

↑ Return to Top

3.2.3. Add ReverseForwarder packages to Nano Server

Once we have copied the 2 ReverseForwarders CAB files, you will need to connect to the Nano Server remotely using Enter-PSSession and use DISM to add the package to your existing Nano Server.

# Add ReverseForwarder package to Nano Server

dism /online /add-package /packagepath:C:\Packages\Microsoft-OneCore-ReverseForwarders-Package.cab

Next, you will require to add the en-us language version of ReverseForwarders package.

# Add en-us language ReverseForwarder package to Nano Server

dism /online /add-package /packagepath:C:\Packages\en-us\Microsoft-OneCore-ReverseForwarders-Package.cab

# Restart the Nano Server remotely

Restart-Computer -Force ;

↑ Return to Top

3.3. Deploying httpPlatformHandler v1.2 x64 to Nano Server

After we have IIS and ReverseForwarders package deployed on the Nano Server, we will require to deploy httpPlatformHandler for ASP.NET 5 application.

3.3.1. Download httpPlatformHandler v1.2 x64 from a Management Server

Let's download the httpPlatformHandler MSI to the Management Server so that we can extract the files.

# Create a Temp folder

New-Item `

    -Path "C:\Temp" `

    -Type directory ;

# Download HttpPlatformHandler v1.2 x64 to C:\Temp

Invoke-WebRequest `

    -Uri "http://go.microsoft.com/fwlink/?LinkId=690721" `

    -OutFile "C:\Temp\httpPlatformHandler_amd64.msi" ;

# Verify HttpPlatformHandler v1.2 x64 has been downloaded

Get-ChildItem `

    -Path "C:\Temp\httpPlatformHandler_amd64.msi" ;

↑ Return to Top

3.3.2. Extract httpPlatformHandler content on Management Server

After the download, we will extract the httpPlatformHandler MSI to a temporary location and copy the content to the Nano Server remotely.

# Extract httpPlatformHandler v1.2 x64 MSI Files

Start-Process `

    -FilePath msiexec.exe `

    -ArgumentList "/a C:\Temp\httpPlatformHandler_amd64.msi /qb TARGETDIR=C:\Temp\httpPlatformHandler_v1.2_amd64" `

    -Wait `

    -PassThru ;

↑ Return to Top

3.3.3. Copy httpPlatformHandler content to Nano Server remotely

Now, you will copy those httpPlatformHandler files to the appropriate location on Nano Server.

# Copy the HttpPlatformHandler.dll file

#  from extracted folder to Nano Server remotely

Copy-Item `

    -Path "C:\Temp\httpPlatformHandler_v1.2_amd64\inetsrv\HttpPlatformHandler.dll" `

    -Destination "\192.168.100.24\C$\Windows\System32\inetsrv" ;

# Copy the httpplatform_schema.xml file

#  from extracted folder to Nano Server remotely

Copy-Item `

    -Path "C:\Temp\httpPlatformHandler_v1.2_amd64\inetsrv\config\schema\httpplatform_schema.xml" `

    -Destination "\192.168.100.24\C$\Windows\System32\inetsrv\config\schema" ;

↑ Return to Top

3.3.4. Configure Internet Information Services (IIS) to allow httpPlatformHandler

After we have copied those httpPlatformHandler files to Nano Server, we need to configure the IIS use the httpPlatformHandler.

# Import IIS Administration PowerShell Module

Import-Module IISAdministration ;

# Add AppSettings section (for Asp.Net Core)

(Get-IISServerManager).GetApplicationHostConfiguration().RootSectionGroup.Sections.Add("appSettings") ;

# Unlock handlers section

(((Get-IISServerManager).GetApplicationHostConfiguration()).GetSection("system.webServer/handlers")).OverrideMode = "Allow" ;

# Add httpPlatform section to system.webServer

((Get-IISServerManager).GetApplicationHostConfiguration().RootSectionGroup.SectionGroups["system.webServer"].Sections.Add("httpPlatform")).OverrideModeDefault = "Allow" ;

# Add httpPlatformHandler.dll to globalModules

New-IISConfigCollectionElement `

    -ConfigCollection (Get-IISConfigSection "system.webServer/globalModules" | Get-IISConfigCollection) `

    -ConfigAttribute @{"name"="httpPlatformHandler";"image"="%SystemRoot%\system32\inetsrv\httpPlatformHandler.dll"} ;

# Add httpPlatformHandler module to modules

New-IISConfigCollectionElement `

    -ConfigCollection (Get-IISConfigSection "system.webServer/modules" | Get-IISConfigCollection) `

    -ConfigAttribute @{"name"="httpPlatformHandler"} ;

# Commit Changes on IIS Server Manager

(Get-IISServerManager).CommitChanges() ;

↑ Return to Top

3.4. Create an ASP.NET 5 site on Nano Server

Finally, we will have to create the ASP.NET 5 site on the Internet Information Services (IIS) in the Nano Server.

# Create a folder

New-Item `

    -Path "C:\ASP-Site" `

    -Type directory ;

# Create a folder

New-Item `

    -Path "C:\ASP-Site\wwwroot" `

    -Type directory ;

# Create a new IIS Website for ASP.NET 5

New-IISSite `

    -Name "ASP-on-NanoServer" `

    -BindingInformation "*:5004:asp.nanoserver.naboo.co.nz" `

    -PhysicalPath "C:\ASP-Site\wwwroot" ;

# Allow HTTP 5004 through Windows Firewall

New-NetFirewallRule `

    -Name "AspNetCore" `

    -DisplayName "HTTP on TCP/5004" `

    -Protocol tcp `

    -LocalPort 5004 `

    -Action Allow `

    -Enabled True ;

# Verify the new IIS Site is created

(Get-IISServerManager).Sites

↑ Return to Top

4. Conclusion

That is all for preparing the Internet Information Services (IIS) with ASP.NET 5 capabilities. The remaining work will require you to copy your published ASP.NET project across to the IIS site path which is more related to ASP.NET article such as installing .NET Version Manager (DNVM), working with .NET Execution Environment (DNX) and .NET Development Utilities (DNU) to compile and publish the output to be copied across to the IIS site path.

↑ Return to Top

5. References

↑ Return to Top

6. See Also

↑ Return to Top