Recently I blogged about ‘Deploying the ASP.Net5 based MVC6 application on IIS which was developed using VS 2015’.
The scope of this blog is to ‘Deploying ASP.NET 5 website on IIS with VS and configure the IIS to access this website’.
Below is the systematic approach to achieve this requirement:
I will be explaining the step by step procedure using the MVC6 sample application downloaded from below location which is available in the githubsite:
You then need to create a folder structure like below:
Under approot folder you need to place the CoreCLR runtime version needed for your application.
You can get this from the User Profiles location:
Note:If you wonder- “How I got the various CoreCLR runtime versions within my user profiler ?”
Refer this blog.
You need to copy the concerned runtime version and place it under the runtimes folder within the approot.
In my scenario, I have used dnx-coreclr-win-x188.8.131.52-rc1-update1 runtime and placed it under the runtimes folder within the approot as shown below:
Create a folder src and place your application folder which has the source code contents within this, as shown below:
Note: Remove the wwwroot from your application and paste its contents within the wwwroot folder that you have created in Step 1 .
Create a cmd file restorePackages.cmd within the approot folder. Place the below content within this cmd file:
@"%LOCAL_DNX%" restore --packages "%~dp0packages" "%~dp0src\HelloMVC"
This cmd file would be used to restore the packages. This cmd file internally runs the dnu restore command on your application and creates the folder ‘packages’ within the approot folder.
In the script, ‘ ~dp0 ’ stands for absolute path of approot folder.
Make sure that you modify the above highlighted section accordingly as per your application requirements.
Create a file called global.json within the approot folder and place the below content within it:
global.json file would be used by the application inside the src to use the concerned runtime version load the dependencies from the packages folder. Note the above highlighted section which needs to be modified accordingly.
You need to then navigate to the approot folder from elevated CMD prompt and run the restorePackages.cmd file.
Microsoft .NET Development Utility CoreClr-x64-1.0.0-rc1-16231
Restoring packages for C:\inetpub\DNX_Demo\approot\src\HelloMVC\project.json
Writing lock file C:\inetpub\DNX_Demo\approot\src\HelloMVC\project.lock.json
Restore complete, 1562ms elapsed
Create a file called web.cmd with the below contents within the approot folder:
IF EXIST %LOCAL_DNX% (
for %%a in (%DNX_HOME%) do (
IF EXIST %%a\runtimes\%DNX_FOLDER%\bin\dnx.exe (
IF "%HOME_DNX%" NEQ "" (
IF "%DNX_PATH%" == "" (
@"%DNX_PATH%" --project "%~dp0src\HelloMVC" --configuration Release web %*
Now looking into the final folder structure, you will see the below:
Open the wwwroot folder and create a web.config file under this with the below contents:
<?xml version="1.0" encoding="UTF-8"?>
<add name="httpplatformhandler" path="*" verb="*"
modules="httpPlatformHandler" resourceType="Unspecified" />
<httpPlatform processPath="..\approot\web.cmd" startupTimeLimit="3600"
stdoutLogEnabled="true" stdoutLogFile="..\logs\stdout.log" />
We are all set now, to create our website in IIS.
Configuring the IIS to proxy the request to DNX:
Open the IIS Manager and create a test site and point it to the wwwroot folder that you created in Step 1 above
Set the application pool to No Managed Code since ASP.NET 5 runs in a separate process and manages the runtime
· You can browse it now to see if your application comes up fine.
If you run in to any issues, you can refer to the logs under the ..\logs\stdout.log file.
Alternatively, you can also enable the Failed Request Tracing Rules available in IIS to see if you can identify the cause and take suitable actions to fix it.