Priyu Kale

Priyu Kale

  • NA
  • 10
  • 5.3k

When to use TempData vs Session in ASP.Net Core ?

Jan 17 2018 5:22 AM
People who used TempData in ASP.NET MVC, probably knows that by default TempData is stored in a Session state. This means that the web application must have sessions enabled. Now, the ASP.NET Core 2.0 gives two TempData providers; a Cookie based and a Session State-based. This blog shows how to use both of them in an application in ASP.NET Core.
 
By default, ASP.NET Core 2.0 makes use of cookies based TempData provider. This means values of TempData are stored in cookies present in the client’s machine. Since TempData gest stored in cookies you don’t require Session state through the session state middleware.
 
So how to store TempData in cookies that coulde be useful it ? 
 

Answers (1)