Sunday, August 7, 2011

Reminder on Sessions

public ActionResult Index(FormCollection formCollection)
{

   if (formCollection["specificField"] != null)

   {

      Foo foo = new Foo(formCollection);

      Session["Bar"] = foo;

   }

   if (Session["Bar"] != null)

   {

      Foo foo = Session["Bar"] as Foo;


      whatever...

This shows how to set, call, and check for a session variable. Destroy a session variable by setting it to null.

No comments:

Post a Comment