Пример #1
0
        public ActionResult WriteTempData(Contact contact)
        {
            TempData["ContactInformation"] = contact;
            TempData["SuccessMessage"] = "Great job";

            return RedirectToAction("ReadTempData");
        }
Пример #2
0
        public ActionResult WriteCookie(Contact contact)
        {
            HttpCookie myCookie = CreateCookie();
            myCookie["Name"] = contact.Name;
            myCookie["Email"] = contact.Email;
            
            Response.Cookies.Add(myCookie);

            return RedirectToAction("ReadCookie");
        }
Пример #3
0
        public ActionResult ReadCookie()
        {
            Contact contact = new Contact();
            var cookie = Request.Cookies[CookieName];
            if (cookie != null)
            {
                contact.Name = cookie["Name"];
                contact.Email = cookie["Email"];
            }
            else
            {
                contact.Name = "No Cookie";
            }


            return View(contact);
        }
Пример #4
0
        public ActionResult ReadSession()
        {
            Contact contact = new Contact();

            if (Session["ContactInformation"] != null)
            {
                contact = (Contact) Session["ContactInformation"];
            }
            else
            {
                contact = new Contact()
                {
                    Name = "No Session",
                    Email = "Fail!"
                };
            }
            return View(contact);
        }
Пример #5
0
        public ActionResult ReadTempData()
        {
            Contact contact = new Contact();

            if (TempData["ContactInformation"] != null)
            {
                contact = (Contact)TempData["ContactInformation"];
            }
            else
            {
                contact = new Contact() { Name = "No TempData", Email = "Fail!" };
            }
            //string msg;
            //if (TempData["SuccessMessage"] != null)
            //{
            //    msg = (string)TempData["SuccessMessage"];
            //}
            //else
            //{
            //    msg = "No message";
            //}

            return View(contact);
        }
Пример #6
0
 public ActionResult WriteSession(Contact contact)
 {
     Session["ContactInformation"] = contact;
     return RedirectToAction("ReadSession");
 }