操作步骤
- 下载dotnet-hosting-6.0.0-rc.1.21452.15-win.exe并安装,成功后检查IIS模块中是否有AspNetCoreModuleV2
- 安装VS时选择“开发时IIS支持”
- 在IIS中创建站点,目录指向开发项目wwwroot的上级目录,应用程序池默认与站点名称相同
- 将刚新建站点的应用程序池的.NET CLR版本改成无托管代码
- 在项目启动配置文件中添加配置(也可在项目属性调试中配置)
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://xxx.xxxx.com",
"sslPort": 0
}
},
"profiles": {
"IIS": {
"commandName": "IIS",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
- 在项目中添加web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="binDebug
et6.0Web.exe" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" hostingModel="inprocess" arguments="">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>