How does one share session in ASP.NET Core 3 between 2 servers (load balanced)? And can session be shared between several web services/APIs and the main ASP.NET MVC app?
I am very new to .NET Core 3, I was used to working with session state in ASP.NET Framework MVC (where it was as simple as using the same machine key in the IIS configuration of the site) but I've learned that everything changed for .NET Core 3, in addition a lot of documentation is extremely outdated/obsolete as new versions have rolled out, .NET core 1 has nothing to do with later versions and 2 with 3, and also it requires many NuGet packages which may or may not work anymore.
Currently I have successfully implemented SQL session store with .NET Core 3 but the option of machine key no longer shows up in the IIS and I really don't know how to configure them in the appsettings.json
file (if still used at all).
Our setup is 2 servers which must both share the session info, with an F5 load balancer, our old apps which use .NET Framework MVC are configured like this, and I need help with achieving the same result but with .NET Core 3.
I read through https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/web-farm?view=aspnetcore-3.1 but it doesn't really explain how to actually do anything
Also this https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-3.1 helped configure the SQL session storage but not how to share between the 2 servers
As well as http://www.intstrings.com/ramivemula/articles/jumpstart-44-sql-server-based-session-state-in-asp-net-core-mvc-application/
Have you configured DataProtection? I haven't worked with this in a while, but from memory this was the essential piece for distributed session storage to work in .NET Core
Here's some additional reading about both sessions and DataProtection in .NET Core with bonus mentions for MachineKey - https://andrewlock.net/an-introduction-to-the-data-protection-system-in-asp-net-core/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With