title: RedirectToAction is not working with Tempdata - ASP.net core MVC
body: <p>I have this method in which I am trying to redirect the request to a different controller. To the called controller , I need some data from the previous controller and so I had this put in the Tempdata. But when I use Tempdata before the line where I call RedirectToAction, the requested is not getting passed to the next action at all </p>
  
  <p>Like in the below code </p>
  
  <pre><code>public IActionResult GetAuthToken()
          {
              //Logic to generate AuthToken 
  
              //TODO:SRI 14/03/2017 Get the UserId from the front end app, For now I am hardcoding this value
  
              AccountHolderDetails user = new AccountHolderDetails
              {
                  UserId = "123",
                  FirstName = "",
                  LastName = "",
                  Email = "",
                  Phone = "",
                  Address = new UserAddress
                  {
                      Street = "123 anystreet",
                      City = "Brantford",
                      State = "ON",
                      Country = "CA"//,
                                    //PostalCode = "M4P1E8"
                  }
              };
  
              var uniqueId = Guid.NewGuid();
              var authToken = GenerateAuthToken(user.UserId, uniqueId);
              var transactionRecord = CreateTransactionRecord(user,uniqueId,authToken);
  
              // HttpContext.Session.Set("UserData", user);
  
              TempData["UserData"] = user;
              TempData["TransactionData"] = transactionRecord;
  
              return RedirectToAction("Authorize", "Authorization");
  
          }
  </code></pre>
  
  <p>I am setting the Tempdata just before calling redirecttoaction, and when the code executes it is not going to the Authorization controller to thw authorize method.</p>
  
  <p>I tried commenting the tempdata part of the lines in above code and it is working fine,but I need the user data in the authorization controller and hence using tempdata. I have followed instructions from the core website to configure sessions and all of that is fine like below check out my starttup.cs class</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
          {
              services.AddDistributedMemoryCache();
              services.AddSession(options =&gt; {
                  options.IdleTimeout = TimeSpan.FromSeconds(10);
                  options.CookieHttpOnly = true;
  
              });
  
              // Add framework services.
              services.AddMvc();
  
              services.Configure&lt;WireCardSettings&gt;(Configuration);
  
              services.AddSingleton&lt;ITempDataProvider, CookieTempDataProvider&gt;();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
          {
              loggerFactory.AddConsole(Configuration.GetSection("Logging"));
              loggerFactory.AddDebug();
  
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
                  app.UseBrowserLink();
              }
              else
              {
                  app.UseExceptionHandler("/Home/Error");
              }
  
              app.UseStaticFiles();
  
              app.UseSession();
  
              app.UseMvc(routes =&gt;
              {
                  routes.MapRoute(
                      name: "default",
                      template: "{controller=Home}/{action=Index}/{id?}");
              });
          }
      }
  </code></pre>