Web.config 在根目录和我的子文件夹中。如何将子文件夹中的文件定义为应用程序的主文件?

Web.config in the root directory and in my subfolder. How to define the file in my subfolder as the main one for my application?

提问人:Arael Huerta 提问时间:10/21/2023 最后编辑:Lex LiArael Huerta 更新时间:10/23/2023 访问量:38

问:

我在 wwwroot (Finance) 的子文件夹中有一个应用程序,它工作正常,但其他人安装了另一个应用程序,而不是在子文件夹中,而是在 wwwrooot 中。 因此,在 wwwroot 和我的子文件夹中有一个 web.config。 当我运行我的应用程序时,它不再读取我的文件,而是读取根目录中的文件。无论其他应用程序是否安装不正确,如何将应用程序配置为读取我的文件而不是 root 文件? IIS 或我的 web.config 中的任何配置?

目前存在:

  • C:\inetpub\wwwroot\web.config
  • C:\inetpub\wwwroot\Finance\web.config

我尝试:

<location path="." inheritInChildApplications="false">
  .......
</location>

在我的web.config的不同部分,但不起作用。 我的web.config:

<configuration>
   <appSettings>
    .......
   </appSettings>
  <connectionStrings>
    .......
  </connectionStrings>
  <system.web>
    .......
  </system.web>
  
  <system.webServer>
    .......
  </system.webServer>
  <system.web.extensions>
    .......
  </system.web.extensions>
</configuration>
asp.net iis web-config wwwroot

评论

0赞 Lex Li 10/21/2023
请学习一些 Markdown 语法,这样你就不需要其他人来解决问题了。

答:

0赞 samwu 10/23/2023 #1

请检查配置是否正确,在根目录的文件夹中,web.config 将 <system.web> 元素包装为以下元素:

<location path="." inheritInChildApplications="false">
   <system.web>
   </system.web>
</location>

并保持所有其他设置元素不变。