上下文:Windows 2016、VS 2022 - 17.5.1(截至目前的最新版本,2023 年 3 月 13 日)、使用 Giraffe 框架的 .Net 6.0 F# Web 应用程序、IIS Express 10(产品版本 10.0.25095.1000)。
注意:我在管理员模式下运行 VS 2022。
当我使用 IIS Express 在 VS 2022 中以开发模式运行应用程序时,我想将 /Scripts 路径重定向到另一个包含大量 JavaScript、css、图像等文件的文件夹:
d:\webapps\webroot\Scripts
.
这是我在
applicationhost.config
文件中的内容:
<applicationPools>
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
<add name="MyApp AppPool" managedRuntimeVersion=""/>
<add name="MyApp AppPool 2" autoStart="true" />
<applicationPoolDefaults managedRuntimeVersion="v4.0">
<processModel />
</applicationPoolDefaults>
</applicationPools>
...
<sites>
<site name="MyApp" id="2">
<application path="/" applicationPool="MyApp AppPool">
<virtualDirectory path="/" physicalPath="D:\webapps\webroot" />
</application>
<application path="/MyApp" applicationPool="MyApp AppPool 2">
<virtualDirectory path="/" physicalPath="D:\webapps\MyApp\src\MyApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51582:localhost" />
<binding protocol="https" bindingInformation="*:44339:localhost" />
</bindings>
</site>
</sites>
我遇到的问题是 /Scripts 下的任何请求都会返回 404。
您在上面看到的配置曾经在我拥有的以前版本的 VS 2022 中工作。不再。也许是升级到 17.5.1 导致它崩溃了——我在星期四升级了 VS 2022。更糟糕的是,今天,它工作了一段时间,然后就停止工作了,这不是一个好兆头。我当然重启了 VS 2022,但我没有重启 Windows。我想我不应该这样做。我有很多我使用的应用程序是开放的。
以下是我注意到的一些事情:
"C:\Program Files\IIS Express\iisexpress.exe" /config:"D:\webapps\MyApp\src\.vs\MyApp\config\applicationhost.config" /site:"MyApp"
一切正常(只要我之前设置了 set ASPNETCORE_ENVIRONMENT=Development
和 set LAUNCHER_PATH=D:\webapps\MyApp\src\MyApp\bin\Debug\net6.0\MyApp.exe
.htts://localhost:44339/MyApp/
."C:\Program Files\IIS Express\iisexpress.exe" /config:"D:\webapps\MyApp\src\.vs\MyApp\config\applicationhost.config" /site:"MyApp" /apppool:"MyApp AppPool 2"
。注意 /apppool
论点。它没有记录:https://learn.microsoft.com/en-us/iis/extensions/using-iis-express/running-iis-express-from-the-command-line。我有预感,这个参数是导致问题的原因。也许它告诉 IIS Express 启动MyApp AppPool 2
,而它忽略了另一个池MyApp AppPool
。但我在这里可能是错的,因为我也尝试为 autoStart=true
池添加 MyApp AppPool
属性但它没有用。我将 applicationPool="Clr4IntegratedAppPool"
设置为 application path="/"
但这也不起作用。所以,在这一点上我很难过。当我在 VS 2022 中调试应用程序时,您对如何使此配置正常工作有什么建议或想法吗?
TIA
更新:我重启了windows - 重启后问题仍然存在。