简体   繁体   中英

ASP.NET 5 project hosting on IIS

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.

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.

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

Visual Studio 2015发布窗口

2. Create a new application in IIS:

添加网站IIS管理器按钮添加网站IIS管理器窗口

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

在此处输入图片说明

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)

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM