此文用于记录在win10环境下,新建的Asp.net Core 2.0 Web应用项目如何运行在IIS上
一、运行环境
操作系统: Window10 家庭中文版 版本 10.0.15063 版本 15063 IDE: Visual Studio Community 2017 Net Core 2.0
二、确定IIS是否有安装Core 2.0模块
因为Asp.net Core 2.0是不需要应用程序池托管的,所以先要安装CoreModule在IIS上用于转发
托管 ASP.NET Core 应用有多种方式,即可在传统的windows平台,也可以部署在开源的Linux上,还可以通过docker容器来部署
![](https://upload-images.jianshu.io/upload_images/1058445-1d9667e1f25e99ac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
打开IIS查看模块.png
![](https://upload-images.jianshu.io/upload_images/1058445-f26014460ff8eaec.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
CoreModule.png
如果没有,需要点击此处 下载Core SDK和Windows Server Hosting (.exe) ,具体位置如下图
![](https://upload-images.jianshu.io/upload_images/1058445-9bca094432f79291.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
位置如图
下载完成后安装即可,其中Core SDK安装后需要重启电脑
三、发布Asp.net Core 2.0 Web 应用
新建一个Asp.net Core 2.0 Web 应用,右键项目-发布
![](https://upload-images.jianshu.io/upload_images/1058445-c4dcb52c09c30f3e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
选择简单的框架.png
![](https://upload-images.jianshu.io/upload_images/1058445-3d7777efe4cffe2d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
点击发布.png
![](https://upload-images.jianshu.io/upload_images/1058445-ef7eddc3346dde20.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
选择文件夹.png
打开IIS添加应用程序池,这里注意一定要选择【无托管代码】
![](https://upload-images.jianshu.io/upload_images/1058445-eec1b18ff20a25c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/316)
打开IIS.png
![](https://upload-images.jianshu.io/upload_images/1058445-b778b2988352b8fb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
配置完成后浏览.png
这次应该是失败的
![](https://upload-images.jianshu.io/upload_images/1058445-77e8df105bb1e59f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
失败页面.png
这个失败是因为没有IIS权限进入目录读取到文件,所以我们进入到相关的目录为其添加Everyone控制 文件目录可以查看发布页面,如下图
![](https://upload-images.jianshu.io/upload_images/1058445-e70608c0974e127c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
查看发布目标位置.png
右击目录为其添加Everyone权限,流程如下图
![](https://upload-images.jianshu.io/upload_images/1058445-ec80e034acd26243.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/435)
编辑.png
![](https://upload-images.jianshu.io/upload_images/1058445-ecc42367ff7b26dd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/435)
添加.png
![](https://upload-images.jianshu.io/upload_images/1058445-1c6fe63853158517.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/546)
输入Everyone.png
![](https://upload-images.jianshu.io/upload_images/1058445-61aeee4c9ab2f39b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/435)
更改Everyone权限.png
四、再次浏览IIS网站
大功告成![](https://upload-images.jianshu.io/upload_images/1058445-62734c51f6e290e1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
https://www.jianshu.com/p/be3d6c5992cc
哇喔.png
五、后记
昨晚(20180107)才安装完成的VS2017,就迫不及待地尝试新的Asp.net Core Web项目 ASP.NET Core 是一个跨平台的高性能开源框架,暂时我还找不到如何不发布就能在IIS上跑起来,这样对于调试来说好像是有点不太方便.(毕竟每次查看localhost都要发布一次,而且要停止网站才能正常发布)
未解决的问题:在新建的Web应用程序中(非MVC),发布后会自动引用CDN中的jquery文件,由于不能正常连接CDN网址而导致样式不能使用。
作者:温工做笔记的地方 链接:https://www.jianshu.com/p/be3d6c5992cc 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。