Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear specific TempData

Tags:

c#

asp.net-mvc

How to clear specific TempData in asp.net mvc. I am using more than two TempData var. I can to clear specific some of them.

TempData["USD"] = "updated";
TempData["EUR"] = "updated";
TempData["PKR"] = "updated";

TempData.Clear() will clear all TempData, how to do this for specific

like image 252
trighati Avatar asked Oct 06 '16 13:10

trighati


2 Answers

just this worked for me fine, only removed TempData["USD"]

TempData.Remove("USD");
like image 143
trighati Avatar answered Oct 06 '22 00:10

trighati


var value = filterContext.Controller.TempData["value"];
filterContext.Controller.TempData.Remove("value");
like image 44
huse.ckr Avatar answered Oct 05 '22 23:10

huse.ckr