简体   繁体   English

在IIS上托管ASP.NET 5项目

[英]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. 我想托管我的ASP.NET 5项目,该项目在Amazon免费微型实例上使用MVC 6和Entity Framework 7。 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. 我找不到任何有关如何在IIS上托管ASP.NET 5项目的分步指南,所有材料都提到这是可能的,但没有任何指南。 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. 不幸的是,我不能使用Azure,因为它只有一个月的免费试用期,而没有一年。

I'm using Visual Studio 2015 Preview to create ASP.NET 5 projects. 我正在使用Visual Studio 2015预览版创建ASP.NET 5项目。 I don't think that's difficult to deploy on IIS now. 我认为现在在IIS上部署它并不困难。 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. 首先,通过在VS 2015预览中将其发布为文件系统来发布网站,然后将发布的文件夹复制到服务器,在IIS中创建应用程序,然后将应用程序文件夹设置为wwwroot文件夹(而不是根文件夹)。 Be aware, check if "Microsoft.AspNet.Server.IIS" exists in your website project.json before publishing it. 请注意,发布之前,请先检查网站project.json中是否存在“ Microsoft.AspNet.Server.IIS”。

Edit: there should be a web.config in wwwroot folder, the content of web.config may be like this (with precompile option when publishing): 编辑:wwwroot文件夹中应该有一个web.config,web.config的内容可能是这样的(发布时带有预编译选项):

<?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 . 请注意kre-app-base的值。 Occasionally its value is empty string after publishing in Visual Studio. 在Visual Studio中发布后,有时其值为空字符串。

1. First you need to publish the site to the file system: 1.首先,您需要将该站点发布到文件系统:

Visual Studio 2015发布窗口

2. Create a new application in IIS: 2.在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: 3.在步骤2的网站目录中解压缩您在步骤1中创建的文件。该文件夹应如下所示:

在此处输入图片说明

4. You may also need to install DNVM (formerly KVM) and the DNX Runtime Environment (formerly KRE): 4.您可能还需要安装DNVM(以前称为KVM)和DNX运行时环境(以前称为KRE):

Install the DNVM - dotnet version Manager (KVM) 安装DNVM-dotnet版本管理器(KVM)

Install the DNX runtime environment inside DNVM (KRE) 在DNVM(KRE)中安装DNX运行时环境

I had the same problem with DNX Beta 4. 我在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. 在Visual Studio 2015 RC中发布网站并在IIS网站配置的“物理路径”中写入“ XXX \\ wwwroot”时,必须以x64框架(目标DNX版本)为目标。

You can use the File system publish method. 您可以使用文件系统发布方法。 Follow these steps: 跟着这些步骤:
1/ Generate in a folder with Visual studio the .dll files 1 /在Visual Studio的文件夹中生成.dll文件
2/ Create a website in IIS manager and give in the path to your folder 2 /在IIS管理器中创建一个网站,并输入文件夹的路径

I found what I've missed, I need to change url to my public DNS in projct.json file: 我找到了我想念的东西,我需要在projct.json文件中将URL更改为我的公共DNS:

"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://ec2-54-68-21-4.us-west-2.compute.amazonaws.com/ “ 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 然后将网站上传到Amazon之后,我需要在网站根目录中运行web.cmd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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