Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. [SessionState(System.Web.SessionState.SessionStateBehavior.Required)]
  2. public class HomeController : Controller
  3. {
  4. // GET: Home
  5. public ActionResult Index()
  6. {
  7. return View();
  8. }
  9.  
  10. public async Task<ActionResult> Check1()
  11. {
  12. Session["Test"] = "Check";
  13. System.Diagnostics.Debug.WriteLine("Session: " + Session["Test"]);
  14. await Task.Delay(20000);
  15. return View();
  16. }
  17.  
  18. public ActionResult Check2()
  19. {
  20. var test = Session["Test"];
  21. ViewBag.Test = test;
  22. return View();
  23. }
  24. }
  25.  
  26. @{
  27. ViewBag.Title = "Check1";
  28. }
  29.  
  30. <h2>View with Delay</h2>
  31.  
  32. @{
  33. ViewBag.Title = "Check2";
  34. var check = ViewBag.Test;
  35. }
  36.  
  37. <h2>Immediate View @check</h2>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement