Distributed session providers

So far, you have learned how to activate and use session state. However, most of the time, you will have multiple web servers, not just one, especially in today's cloud environments. So, how do you store session state out of memory in a distributed cache?

Well, that's easy  you just have to register additional services within the Startup class. These additional services will provide this functionality. Here are some examples:

  • Distributed Memory Cache:
        services.AddDistributedMemoryCache(); 
  • Distributed SQL Server Cache:
        services.AddDistributedSqlServerCache(o => 
        { 
          o.ConnectionString = _configuration["DatabaseConnection"]; 
          o.SchemaName = "dbo"; 
          o.TableName = "sessions"; 
        }); 
  • Distributed Redis Cache:
        services.AddDistributedRedisCache(o => 
        { 
          o.Configuration = _configuration["CacheRedis:Connection"]; 
          o.InstanceName = _configuration
["CacheRedis:InstanceName"]; });

We have added a new User Interface Language Drop-Down in this section, but you haven't learned how to handle multiple languages within your applications yet. There's no time to lose; let's learn how to do this and use the drop-down and session variable for changing the user interface language on the fly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.255.190