I was learning about the HttpContext
and found out that
HttpContext object will be constructed newly for every request given
to an ASP.Net application
Now, consider a case, when I have two pages. WebForm1 and Webform2. In Form1, I am writing the below mentioned code and redirects to form2.
HttpContext.Current.Items.Add("Key", "Value");
Query
When I use Server.Transfer this key persist and this is not the case while using Response.Redirect
Confusion
Wnenever a new request is generated, HttpCopntext object is created. Moreover, Session is preserved. Which is part of HttpContext.
HttpContext.Current.Session
If Session can persist, why can't HttpContext.Current.Items
in Response.Redirect
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…