hosting multiple asp.net core applications

2

I am trying create a web app container and have another asp.net core application under it . the tree structure is something like this on IIS.

Main Application (my.localhost.com/) Sub Application (my.localhost.com/subapp)

after Publishing the projects to IIS and viewing my.localhost.com in browser ever thing works fine but when i access my.localhost.com/subapp I get following error

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

when from the published web.config (which is auto generated by asp.net core) i remove following handler every thing seems to be working fine.

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

now i cant figure out a way to exclude this from web.config file. Any suggestions how this can be handled. Please help

asp.net-mvc
iis
asp.net-core
asp.net-core-mvc
asked on Stack Overflow Sep 9, 2017 by Umar Khan

2 Answers

1

As you wrote, you have to define the aspNetCore handler only in the root level web.config. In the sub applications you only define the application that uses the handler. This is problematic because publish automatically either generates or transforms the web.config with the handler specification.

For ASP.NET Core (and the new project file format) you can disable web.config transformations with <IsTransformWebConfigDisabled>False</IsTransformWebConfigDisabled>. This of course means that you have to write the web.config by hand as it is not generated.

answered on Stack Overflow Jan 9, 2018 by aksu
1

I had to add a new web.config (one did not exist) then uncomment the content in it

<?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>
answered on Stack Overflow Jun 29, 2019 by Matt Searles

User contributions licensed under CC BY-SA 3.0