整理了一下.Net Core在 Windows 中的托管,把经验分享给大家。
方法一:使用IIS进行托管
本人用的是.net Core 2.1.1,首先需要安装dotnet-sdk-2.1.801-win-x64.exe和DotNetCore.1.0.4_1.1.1-WindowsHosting.exe
如果你创建的是API项目,直接发布并选择IIS.net framework的版本就好了
如果是Web应用程序托管到IIS上就必须要有web.config文件,添加web.config的方式,先在本地创建web.config文件,再添加到项目中,如下内容
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00"> <environmentVariables /> </aspNetCore> </system.webServer> </configuration>
选择发布
在IIS添加网站
修改应用程序池
OK,这样.Net Core就完全托管到IIS上了