Nov 20, 2019 07:38 PM|mgebhard|LINK
The code snippet below might indicate that you do not understand how TempData and the Keep() method work in ASP.NET Core as the code is redundant.
TempData["pid"] = 1003;
TempData is kept for one read. Once read, TempData is marked for deletion and not available on subsequent requests. Use Peek(string) to fetch an indexed item from TempData without marking the item for deletion.
I assume you read the "pid" value somewhere along the way when you should have used Peek().
var temp = TempData.Peek("pid");
Another way to do the same is...
int id = Convert.ToInt32(TempData["pid"]);
See the following.