Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scope of HttpContext.Current.Items

Tags:

c#

.net

asp.net

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?

like image 724
Alexandre Brisebois Avatar asked Oct 12 '09 17:10

Alexandre Brisebois


People also ask

What is use of HttpContext current?

What is HttpContext? It holds the current information about the Http request. It contains the information like authorization, authentication, request, response, session, items, users, formOptions, etc. Every HTTP request creates a new object of HttpContext with current information.

What is HttpContext item?

An HttpContext object will encapsulate specific details of a single HTTP request. Properties of this class include the Request object, the Response object, the Session object, and an AllErrors property which keeps an array of Exception objects accrued during the current request.

Is HttpContext current items thread safe?

The HttpContext is NOT thread safe, accessing it from multiple threads can result in exceptions, data corruption and generally unpredictable results.

What is HttpContext current session in asp net?

An ASP.NET application that has session state enabled. A Web Forms page class that has access to the Page. Session property, or any class that has access to the HttpContext.


2 Answers

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

See article The HttpContext Items Collection

like image 77
John Lechowicz Avatar answered Sep 17 '22 15:09

John Lechowicz


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

like image 41
Restuta Avatar answered Sep 20 '22 15:09

Restuta