title: Redis Cache not working with Asp.net core
body: <p>I try to implement redis cache in Asp.Net Core Application but its not Set any value in HttpContext.Session and not even return any value.This is my startup.cs  file.</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddDistributedRedisCache(options =&gt;
          {
              options.InstanceName = Configuration.GetValue&lt;string&gt;("redis:name");
              options.Configuration = Configuration.GetValue&lt;string&gt;("redis:host");
          });
          services.AddSession(o=&gt; { o.IdleTimeout = TimeSpan.FromMinutes(5); });  
          services.AddMvc();
      }
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler("/Home/Error");
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }
          app.UseSession();
  
          app.UseStaticFiles();
  
  
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}");
          });
      }
  </code></pre>
  
  <p>Appsetting.json</p>
  
  <pre><code> "redis": {
  "host": "redis-17930.c1.ap-southeast-1-1.ec2.cloud.redislabs.com",
  "port": 17930,
  "name": "Astroyogi"
    },
  </code></pre>
  
  <p>HomeController.cs</p>
  
  <pre><code>   public IActionResult Index()
      {
          var helloRedis = Encoding.UTF8.GetBytes("Hello Redis");
          HttpContext.Session.Set("hellokey", helloRedis);
  
          var getHello = default(byte[]);
          HttpContext.Session.TryGetValue("hellokey", out getHello);
          ViewData["Hello"] = Encoding.UTF8.GetString(getHello);
  
         return View();
      }
  </code></pre>
  
  <p>and the lib which i installed-
  Microsoft.Extensions.Caching.Redis
  Microsoft.AspNetCore.Session</p>
  
  <p>and its will not set any value in session.
  Please help me where i am stucking.</p>