使.NET6在开发时支持IIS
时间:2022-09-22 10:40:02|栏目:.NET代码|点击: 次
操作步骤
1.下载dotnet-hosting-6.0.0-rc.1.21452.15-win.exe并安装,成功后检查IIS模块中是否有AspNetCoreModuleV2
2.安装VS时选择“开发时IIS支持”
3.在IIS中创建站点,目录指向开发项目wwwroot的上级目录,应用程序池默认与站点名称相同
4.将刚新建站点的应用程序池的.NET CLR版本改成无托管代码
5.在项目启动配置文件中添加配置(也可在项目属性调试中配置)
{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iis": { "applicationUrl": "http://xxx.xxxx.com", "sslPort": 0 } }, "profiles": { "IIS": { "commandName": "IIS", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } }
6.在项目中添加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="bin\Debug\net6.0\Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" arguments=""> <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables> </aspNetCore> </system.webServer> </location> </configuration>
栏 目:.NET代码
下一篇:ASP.NET Core 实现自动刷新JWT Token
本文标题:使.NET6在开发时支持IIS
本文地址:http://www.codeinn.net/misctech/214335.html