I deployed the following apps:
- ASP.NET MVC (.Net Framework 4.7.2) site
- .Net Core 3.1 web API
both on the same IIS server. The site is set up to "/" path and the API to "/api":
Accessing the website from, for example, from localhost opens site fine. However, if I try to access the API (e.g. http://localhost/api) I get this error:
Could not load file or assembly 'Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/inetpub/AspNetCoreWebApps/BackendAPI/
LOG: Initial PrivatePath = C:\inetpub\AspNetCoreWebApps\BackendAPI\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\AspNetCoreWebApps\BackendAPI\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/27eecc96/2976b187/Microsoft.AspNet.SessionState.SessionStateModule.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/27eecc96/2976b187/Microsoft.AspNet.SessionState.SessionStateModule/Microsoft.AspNet.SessionState.SessionStateModule.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/AspNetCoreWebApps/BackendAPI/bin/Microsoft.AspNet.SessionState.SessionStateModule.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/AspNetCoreWebApps/BackendAPI/bin/Microsoft.AspNet.SessionState.SessionStateModule/Microsoft.AspNet.SessionState.SessionStateModule.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/27eecc96/2976b187/Microsoft.AspNet.SessionState.SessionStateModule.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/27eecc96/2976b187/Microsoft.AspNet.SessionState.SessionStateModule/Microsoft.AspNet.SessionState.SessionStateModule.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/AspNetCoreWebApps/BackendAPI/bin/Microsoft.AspNet.SessionState.SessionStateModule.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/AspNetCoreWebApps/BackendAPI/bin/Microsoft.AspNet.SessionState.SessionStateModule/Microsoft.AspNet.SessionState.SessionStateModule.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +96
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +62
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +50
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +572
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +31
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +59
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +59
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +221
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1103
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +122
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +255
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +347
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737
dotnet --info output on the server:
PS C:\Users\Administrator> dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.401
Commit: 4bef5f3dbf
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.401\
Host (useful for support):
Version: 5.0.10
Commit: e1825b4928
.NET SDKs installed:
2.1.818 [C:\Program Files\dotnet\sdk]
3.1.413 [C:\Program Files\dotnet\sdk]
5.0.401 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
The strange thing is that the API project (.Net Core 3.1) does not use "Microsoft.AspNet.SessionState.SessionStateModule" package at all. However, this SessionStateModule package is used by the .Net Framework site (via a classic/4.7.2 library).
I do not understand why the assembly binder (i.e. Fusion) is looking for that package in the "C:\inetpub*BackendAPI\bin folder. There is no "bin" folder where the .Net Core 3.1 app is deployed at all (see LOG: Initial PrivatePath = C:\inetpub\AspNetCoreWebApps\BackendAPI\bin).
What am I missing here? Have a messed up the deployment of those 2 apps somehow?
Thank you in advance