ASP.NET 5 project hosting on IIS

21,101

Solution 1

I'm using Visual Studio 2015 Preview to create ASP.NET 5 projects. I don't think that's difficult to deploy on IIS now. First publish your website by publishing it as file system in VS 2015 preview, then copy the published folder to your server, create an application in IIS and set the application folder to the wwwroot folder (rather than the root folder), that's all. Be aware, check if "Microsoft.AspNet.Server.IIS" exists in your website project.json before publishing it.

Edit: there should be a web.config in wwwroot folder, the content of web.config may be like this (with precompile option when publishing):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="kpm-package-path" value="..\approot\packages" />
    <add key="bootstrapper-version" value="1.0.0-beta1" />
    <add key="kre-package-path" value="..\approot\packages" />
    <add key="kre-version" value="1.0.0-beta1" />
    <add key="kre-clr" value="CoreCLR" />
    <add key="kre-app-base" value="..\approot\packages\Rvc.PopUpSite\1.0.0\root" />
  </appSettings>
</configuration>

or like this (without precompile option):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="kpm-package-path" value="..\approot\packages" />
    <add key="bootstrapper-version" value="1.0.0-beta1" />
    <add key="kre-package-path" value="..\approot\packages" />
    <add key="kre-version" value="1.0.0-beta1" />
    <add key="kre-clr" value="CoreCLR" />
    <add key="kre-app-base" value="..\approot\src\Rvc.PopUpSite" />
  </appSettings>
</configuration>

Please notice the value of kre-app-base. Occasionally its value is empty string after publishing in Visual Studio.

Solution 2

1. First you need to publish the site to the file system:

visual studio 2015 publish window

2. Create a new application in IIS:

Add website IIS manager button Add website IIS manager window

3. Unzip the file you've created in step 1 in the website directory from step 2. The folder should look like:

enter image description here

4. You may also need to install DNVM (formerly KVM) and the DNX Runtime Environment (formerly KRE):

Install the DNVM - dotnet version Manager (KVM)

Install the DNX runtime environment inside DNVM (KRE)

Solution 3

I had the same problem with DNX Beta 4.

If someone has the same problem :

You have to target x64 framework (Target DNX Version) when you publish your website in Visual Studio 2015 RC and write "XXX\wwwroot" in Physical Path in your IIS website configuration.

Solution 4

I found what I've missed, I need to change url to my public DNS in projct.json file:

"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://ec2-54-68-21-4.us-west-2.compute.amazonaws.com/

then after uploading site to Amazon I need to run web.cmd in site root

Solution 5

You can use the File system publish method. Follow these steps:
1/ Generate in a folder with Visual studio the .dll files
2/ Create a website in IIS manager and give in the path to your folder

Share:
21,101
Sergey Sypalo
Author by

Sergey Sypalo

Microsoft Certified Solutions Expert, IT Professional and Systems Engineer in wide range of products with over a 10 years of hands-on experience. I'm expert in planning, testing, configuring, designing and deploying Active Directory, virtualization, messaging, systems management and monitoring servers, including multi-tiered antivirus and backup solutions in large complex networks.

Updated on January 07, 2020

Comments

  • Sergey Sypalo
    Sergey Sypalo over 4 years

    I want to host my ASP.NET 5 project which uses MVC 6 and Entity Framework 7 on Amazon free micro instance. I can't find any step-by-step manual on how to host ASP.NET 5 projects on IIS, all materials just mention that this is possible but without any guides. Basically, I'm deploying to local folder and then copying to newly created site, but nothing is working. Unfortunately, I can't use Azure as it only has one month free trial, not a year.

  • Sergey Sypalo
    Sergey Sypalo over 9 years
    Hi Nikolay, first 3 steps already done, so I've just installed KVM and was unable to run "kvm upgrade" command until changed path to C:\Users\Administrator\.kre\bin> After this I was able to run "kvm upgrade comand" but result the same, when I'm trying to open web pageI'm receiving following error: HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory
  • Sergey Sypalo
    Sergey Sypalo over 9 years
    I've already did this, but site still not opening, see my comment to previous message from Nikolay
  • Sergey Sypalo
    Sergey Sypalo over 9 years
    Hi Ricky, just tried as you said copy published folder to Amazon, so I have my site in C:\Inetpub\wwwroot\Blog on Amazon, created new site in IIS, pointed it to C:\Inetpub\wwwroot\Blog\wwwroot, but it's not working. I have "Microsoft.AspNet.Server.IIS" in roject json. Any Ideas what I'm doing wrong?
  • Ricky
    Ricky over 9 years
    @Sergey just edited my post. I don't know if you can get notification of my edit, so added this comment. It would also be very helpful if you could post the error message you got, if any.
  • Sergey Sypalo
    Sergey Sypalo over 9 years
    Hi Ricky, thx, now it's working. Faced another issue, after changing packages in project.json from *beta-1 to *rc-1, during publishing to local disk both versions are published, do you know how to remove old dependencies?
  • Dylan Parry
    Dylan Parry about 9 years
    The kre-app-base value being empty was the root of all the problems I was having with this. Thanks!
  • Stefan Steiger
    Stefan Steiger over 8 years
    kre has been renamed to dnx
  • Nathan Teague
    Nathan Teague over 8 years
    Does anyone know if this can be set in a json file somewhere?
  • toddmo
    toddmo over 8 years
    I had to publish my wwwroot not in the (very long) default directory from the publish wizard. The path / file names became too long.