11

I am trying to host a multiple ASP.NET Core applications using the same application pool in IIS. But were receiving a 500 error on the other application and only first one hosted is working.

Does anyone know whats the reason behind this?

Note: We tried reducing the module version in web.config "AspNetCoreModuleV2" to "AspNetCoreModule" and the other application worked, but I don't want to use this solution.

3
  • 1
    Why do they need to be in the same app pool? Commented Oct 31, 2019 at 8:11
  • 1
    The aim for application pool is isolate application from the other. Since sharing app pool is not supported by asp.net core, you may need to select other workaround for this. Commented Nov 1, 2019 at 2:28
  • "sharing app pool is not supported by asp.net core" is a false statement, as out-of-process mode can work. Commented Nov 1, 2019 at 13:06

3 Answers 3

22

One app per pool is the design limitation of ASP.NET Core module in-process hosting mode.

Sharing an app pool among apps isn't supported. Use one app pool per app.

You either accept that and use one app per app pool, or switch to out-of-process mode (actually you did that by using the version 1 of ASP.NET Core module).

Sign up to request clarification or add additional context in comments.

Comments

8

Two other alternatives are:

Option 1.

Open the .csproj file and add the below property to apply the proper hosting model.

<PropertyGroup>
   ...
   <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

In ASP.NET Core apps we don't have web.config so first, we have to publish your application and in the published folder you can see there your web.config the file generated by .NET 5 Core. Now open the config file.like as given below.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\DotNetCoreApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

The In-process hosting model is the default model. So if you want to change it to other i.e. Out-of-process then you just need to change hostingModel="OutOfProcess".

Option 2.

In VS2019

  • Close your solution
  • Delete applicationhost.config in folder .vs or delete the whole .vs folder. The .vs is a hidden folder and is next to your solution file usually.
  • Restart your solution again

2 Comments

How does Option 2 work, or affect the situation at all?
@TylerH don't know. We've all moved on now
-1

I tried running multiple sites sharing same application pool and it worked fine, but then sometimes it behaves strangely so better to have separate application pool.

For example you may encounter following error:

Asp.Net Core 2.2 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

To avoid such issues create separate application pool for each .NET Core site.

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2#in-process-hosting-model

Sharing an app pool among apps isn't supported. Use one app pool per app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.