ASP.Net Interview Questions and Answers.


  1. Can you put the ViewState in the Session if yes how and why?

  2. Yes. we can store ViewState in Session.But this Session require good chunk of memory on the server.


    // Store ViewState to Session
    ViewState["myViewState"] = "ASP.Net";
    Session["mySession"] = ViewState["myViewState"];

    // Retrieve ViewState from Session
    ViewState["RetrievedValue"] = Session["mySession"];
    String ViewStateValue = ViewState["RetrievedValue"].ToString();