MVC 3 Session.Abandon (), called before setting TempData ["myvalue"] = "foo", causes the next controller to have TempData as null

I have a controller logic that is looking for: session value

 //checks value null etc..  for existing record in session memory.
 Session["certnum"]  

Then in the controller I decided to have a condition in which:

 //is called to initiate a New Record that will be created.
 Session.Abandon();

However, in procedural encoding, this is Session.Abandon (); precedes the creation of TempData ["myobject"] = "foo", and after passing the code TempData in the next window shows my value, and everything seems to be good. Then, when redirecting to another controller:

return RedirectToAction("ChildInfo", "NewRecord");  

ChildInfo TempData... null. Abandon Session , TempData, , MVC, . TempData, . Session.Abandon(), TempData , .

+5
3

Session.Abandon() , .

. http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.abandon.aspx

, , . Abandon(), .

- , Session.Remove Session.RemoveAll ( Clear , RemoveAll. :

Session.Remove(itemToRemove);

Session.RemoveAll()

, , , , .

+11

Session.Abandon , , . - .

, , , , . , , , .

, , . , , , .

+1

.

Session.Abandon . . .

0

All Articles