I couldn’t find any blogs in the internet which explains the step by step procedure to deploy the ASP.NET 5 application to IIS from Visual Studio 2015.
This blog is written specifically to address this issue.
I will be creating an MVC 6 application in my Visual Studio 2015 Update 1 and deploy to my local IIS and explain how to configure the HTTP Platform Handler.
Ø Firstly, we create the sample MVC 6 application. For this you need to Open VS 2015. Click on FileàNew Projectà Under the New ASP.Net Project template window you can select any one of the below options. I have selected the WebApplication in my example.
Ø Right click on the WebApplication under the Solution Explorer and select Publish
Ø In the Publish Web window, under the Profile tab, you can select File System. You will be asked to Enter a Profile Name as shown below:
Ø Under the Connection tab, you need to specify the Target location:
Ø Under the settings tab, you need to select the Target DNX Version, this is the runtime version against which our application will be compiled.
Ø Under the Preview Tab you can simply click on the Publish button which will deploy your application content to the Target Location specified in step 4
While this happens the Visual Studio will send the information we provided as a parameter to the dnu.cmd location under your user profile Target DNX version selected above.
Connecting to c:\Inetpub\ASPNet_Demo...
Path=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\xxxxx\.dnx\runtimes\dnx-clr-win-x126.96.36.199-rc1-update1\bin\dnu.cmdpublish "c:\users\xxxxx\documents\visual studio 2015\Projects\AspNet_Demo\src\AspNet_Demo" --out "C:\Users\xxxxx\AppData\Local\Temp\PublishTemp\AspNet_Demo98" --configuration Release --runtime dnx-clr-win-x188.8.131.52-rc1-update1 --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web" --quiet
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231
Executing script 'prepublish' in project.json
Then internally the code is published with the help of msdeploy.
Publishing with publish method [FileSystem]
Publishing files to c:\Inetpub\ASPNet_Demo
Executing command ["C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:contentPath='C:\Users\xxxxx\AppData\Local\Temp\PublishTemp\AspNet_Demo98\' -dest:contentPath='c:\Inetpub\ASPNet_Demo' -verb:sync -enableRule:DoNotDeleteRule -retryAttempts:2 -disablerule:BackupRule]
Info: Adding directory (c:\Inetpub\ASPNet_Demo\approot).
Ø Directory structure after publishing:
Ø In the IIS you need to create new website and point it to the wwwroot folder shown above. So the site in IIS would be pointing to the path C:\inetpub\ASPNet_Demo\wwwroot.
Ø Set the application pool to No Managed Code. ASP.NET 5 runs in a separate process and manages the runtime.
The HttpPlatformHandler is an IIS Module which does the following two things:
· Process Management of http listeners – this could be any process that can listen on a port for http requests. For example – Tomcat, Apache, Jetty, Node.exe, Ruby etc;
· Act like a Proxy for the incoming requests to the process that it manages.
Ø We can configure the settings for HttpPlatformHandler at the website level from Configuration Editor:
Ø Below are the default settings that you get after you publish the application:
Ø These settings are picked up from the web.config file under the wwwroot. The web.config file which should have the below lines:
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler"
<httpPlatform processPath="..\approot\web.cmd" arguments=""
Ø We see that the ProcessPath is set to ..\approot\web.cmd. This specifies the ‘Path to the executable or script that will launch a process listening for HTTP requests’.
Ø We see that the web.cmd file exits under the approot which is in the same location as that of wwwroot folder.
Ø You can also see the runtimes folder which has the DNX target version against which our application is compiled. This is the same target version we selected while publishing the application.
Ø Now the ASP.NET5 based MVC 6 application has been deployed successfully on IIS. We can browse it and check the page comes up fine:
If you run into any issues, after configuring the website you need to follow this blog.