Craig Davis

Craig Davis

  • NA
  • 40
  • 0

Server.transfer HTTPcontext.Items

Apr 25 2011 8:54 PM
If I use server.transfer to pass data between pages and a user bookmarks the second page how do I prevent an error e.g.

Page 1 code behind
string var="text";
Context.Items["WebForm1var"] = var;
Server.Transfer("page2.aspx");

Page 2 code behind

string2=Context.Items["WebFormvar"].ToString();
---------------------------------------------------------------------
Can I preface the code in page 2 with

if(Context.Items["WebFormvar"])
{
string2=Context.Items["WebFormvar"].ToString();
}

Answers (1)