【问题标题】:hosting multiple asp.net core applications托管多个 asp.net 核心应用程序
【发布时间】:2018-02-18 03:43:03
【问题描述】:

我正在尝试创建一个 Web 应用程序容器并在其下有另一个 asp.net 核心应用程序。树形结构在 IIS 上是这样的。

主应用程序 (my.localhost.com/) 子应用程序(my.localhost.com/subapp)

将项目发布到 IIS 并在浏览器中查看 my.localhost.com 后一切正常,但是当我访问 my.localhost.com/subapp 时出现以下错误

Detailed Error Information:
Module     IIS Web Core
Notification       BeginRequest
Handler    Not yet determined
Error Code     0x800700b7
Config Error       Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'aspNetCore'
Config File    \\?\C:\ASP.net solutions\Myproject\admin\web.config

当我从已发布的 web.config(由 asp.net 核心自动生成)中删除以下处理程序时,一切似乎都运行良好。

<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> 

现在我想不出办法从 web.config 文件中排除它。任何建议如何处理。请帮忙

【问题讨论】:

    标签: asp.net-mvc iis asp.net-core asp.net-core-mvc


    【解决方案1】:

    正如您所写,您必须仅在根级别 web.config 中定义 aspNetCore 处理程序。在子应用程序中,您只需定义使用处理程序的应用程序。这是有问题的,因为发布会自动生成或转换带有处理程序规范的 web.config。

    对于 ASP.NET Core(和新的项目文件格式),您可以使用 &lt;IsTransformWebConfigDisabled&gt;False&lt;/IsTransformWebConfigDisabled&gt; 禁用 web.config 转换。这当然意味着您必须手动编写 web.config,因为它不是生成的。

    【讨论】:

      【解决方案2】:

      我必须添加一个新的 web.config(一个不存在)然后取消注释其中的内容

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
      
        <!-- To customize the asp.net core module uncomment and edit the following section. 
        For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
      
        <system.webServer>
          <handlers>
            <remove name="aspNetCore"/>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
          </handlers>
          <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
        </system.webServer>
      
      </configuration>
      

      【讨论】:

        猜你喜欢
        • 2020-08-11
        • 2020-09-26
        • 1970-01-01
        • 2018-04-03
        • 2017-12-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-03
        相关资源
        最近更新 更多