ASP.NET Core/5 如何与 IIS Express 集成?
How Does ASP.NET Core/5 Integrate With IIS Express?
我正在解决为什么在我移动 ASP.NET
核心项目后 IIS Express
找不到我的 web.config
。
(HTTP Error 500.19 - Cannot read configuration file - web.config file)
我的研究表明大多数人都在更改 applicationhost.config 文件。但是,当我打开 applicationhost.config 文件时,我只看到默认条目 (WebSite1 不是我的项目名称):
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
我也知道 launchSettings.json 文件有 IIS Express
使用的选项。例如,我在 launchSettings.json
文件中将 localhost port
更改为 4444
:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4444",
"sslPort": 0
}
},
在我移动项目之前,一切正常。此外,如果我选择 运行 我的项目使用 Visual Studio
中的 "web"(我认为是 Kestrel),即使在移动之后它也能正常工作。
所以我的问题是 and/or 我的 ASP.NET
核心应用程序在哪里设置 IIS Express
的特定设置?我特别感兴趣的是如何找到并更改项目的物理路径,以便 IIS Express
可以找到我的 web.config
.
移动项目时,请确保复制根文件夹,以便包含文件夹中的所有文件。听起来您只是复制了不包含所有内容的 "src" 文件夹。
如果您复制根文件夹并打开项目,它将 运行 正常。正如 Lex Li 上面提到的,有一个名为 .vs 的隐藏文件夹,其中包含一个带有 applicationhost.config.
的配置文件夹
我正在解决为什么在我移动 ASP.NET
核心项目后 IIS Express
找不到我的 web.config
。
(HTTP Error 500.19 - Cannot read configuration file - web.config file)
我的研究表明大多数人都在更改 applicationhost.config 文件。但是,当我打开 applicationhost.config 文件时,我只看到默认条目 (WebSite1 不是我的项目名称):
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
我也知道 launchSettings.json 文件有 IIS Express
使用的选项。例如,我在 launchSettings.json
文件中将 localhost port
更改为 4444
:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4444",
"sslPort": 0
}
},
在我移动项目之前,一切正常。此外,如果我选择 运行 我的项目使用 Visual Studio
中的 "web"(我认为是 Kestrel),即使在移动之后它也能正常工作。
所以我的问题是 and/or 我的 ASP.NET
核心应用程序在哪里设置 IIS Express
的特定设置?我特别感兴趣的是如何找到并更改项目的物理路径,以便 IIS Express
可以找到我的 web.config
.
移动项目时,请确保复制根文件夹,以便包含文件夹中的所有文件。听起来您只是复制了不包含所有内容的 "src" 文件夹。
如果您复制根文件夹并打开项目,它将 运行 正常。正如 Lex Li 上面提到的,有一个名为 .vs 的隐藏文件夹,其中包含一个带有 applicationhost.config.
的配置文件夹