14

Are the HttpContext.Current.Items lost when a Server.Transfer(); occurs?

If so what is the best way for me to send information to another page without going through the Session?

George Stocker
  • 57,289
  • 29
  • 176
  • 237
Alexandre Brisebois
  • 6,599
  • 12
  • 50
  • 69

2 Answers2

15

Yes, the context would still be valid. It would become invalid or break if you use Response.Redirect().

See article The HttpContext Items Collection

John Lechowicz
  • 2,573
  • 3
  • 21
  • 34
1

You can access Page.PreviousPage property with all data on it when using Server.Transfer(). And also yes, context would be valid.

Restuta
  • 5,855
  • 33
  • 44
  • 1
    would the context still be valid or would a new context have been built for the call ? – Alexandre Brisebois Oct 12 '09 at 17:24
  • 1
    There is a caveat that applies to referencing controls and their value from Page.PreviousPage via FindControl if the previous page is using a master page. You have to first referenece the content placeholder is that you have to first reference the content placeholder (null checks omitted for brevity): `var cp = this.PreviousPage.Controls[0].FindControl("ContentPlaceHolder1");` `TextBox txtFirstName = (TextBox)cp.FindControl("txtFirstName");` – Charles Byrne Dec 17 '14 at 13:37