在windows IIS服务商配置asp.net core的服务器坏境,并部署

在windows IIS服务商配置asp.net core的服务器坏境,并部署

翻译自https://docs.microsoft.com/en-us/aspnet/core/publishing/iis

另一篇参考的文章

http://www.c-sharpcorner.com/uploadfile/2b481f/how-to-host-asp-net-web-api-on-iis-server/

支持的操作系统:

windows 7或更新

windows server 2008 R2或更新

IIS配置

使能Web server并配置相关选项

windows桌面版系统

在windows IIS服务商配置asp.net core的服务器坏境,并部署

windows server版操作系统

在windows IIS服务商配置asp.net core的服务器坏境,并部署

在windows IIS服务商配置asp.net core的服务器坏境,并部署

 安装.net core windows server托管工具包

1. 安装.NET Core Windows Server Hosting bundle: https://aka.ms/dotnetcore.2.0.0-windowshosting

  如果服务器没有连接互联网,应在安装hosting bundle前下载安装 microsoft visual c++ redistributable https://www.microsoft.com/download/details.aspx?id=53840

2. 重新启动系统或执行

    >net stop was /y

   >net start w3svc

 用visualstudio发布时安装Web Deploy

 如果你希望在vs内用Web Deploy来部署你的应用,请在主机系统上安装最新版的Web Deploy。 

要安装Web Deploy,你可以使用Web Platform Installer(WebPI) https://www.microsoft.com/web/downloads/platform.aspx

或直接从微软下载中心下载 (https://www.microsoft.com/search/result.aspx?q=webdeploy&form=dlc)(注链接不能用)

应用配置

1. 使能IISIntegration component

  包含依赖项 Microsoft.AspNetCore.Server.IISIntegration

  Program.cs中加入一下代码

var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration()
    .UseStartup<Startup>()
    .Build();

2. 配置IISOptions 

3. web.config

创建IIS网站

(注:此管理界面与windows7的IIS管理界面差异很大,在此配置失败,没有进行下去)