By default, TempData
uses a cookie-based provider, which means each piece of data you add goes out as a cookie. It looks like you've added so much here that the header is now too large. The easiest solution is to use session state as a TempData
provider, instead. Then, you'll just have one session cookie going out, regardless of how much data you set in TempData
. In ConfigureServices
add:
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddSessionStateTempDataProvider();
services.AddSession();
And then in Configure
:
app.UseSession();
app.UseMvc();
You'll like also want to configure session to use a persistent store like Redis or SQL Server, rather than the default of in-memory, but that's not directly relevant to the use of TempData
.