1

I have asp.net core web application hosted on Azure.
I've configured Azure Redis Cache to use it as a session store. It works well on Dev where Load Balancer is not configured.
Our UAT & Prod have load balancers configured. And there Redis Session store is not working as expected. I’m facing issue of frequent session timeout.

Following is the current implementation: Startup.cs

services.AddDistributedRedisCache(options =>
{
options.Configuration = Configuration.GetConnectionString(“RedisCache”);
options.InstanceName = “SampleInstance”;
});
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.Name = “SessionCookie”;
});

Added app.UseSession(); in Configure method.

In HomeController Login Action,

HttpContext.Session.SetString(“UserId”, loggedInUser.UserId.ToString());
HttpContext.Session.SetString(“CompanyCode”, loggedInUser.CompanyCode.ToString());

It works in Local & Dev, but fails on environment where Load Balancer is configured.

Please suggest if I’ve missed something.

Priya
  • 1,375
  • 8
  • 21
  • 45

0 Answers0