[C#] HttpContext vs Context

michael_hk

Centurion
Joined
Nov 24, 2003
Messages
199
Location
Hong Kong
Hi guys,

I am using the FrontController pattern and I have the following two aspx pages.

Test1.aspx
Code:
public class handler : IHttpHandler
{
	public void ProcessRequest(HttpContext context)
	{
		...
		context.Items["datatable"] = dt;
		context.Server.Transfer("Test2.aspx");
	}
}

Test2.aspx
Code:
DataTable dt2 = (DataTable)Context.Items["datatable"];

In Test1.aspx I assign a datatable (dt) to context and in Test2.aspx I can use Context to retrieve it. So is it context == Context? :confused:

Thanks for your help.

Michael
 
Context.Items["datatable"] is an object , in this case a DataTable by the look of it , so you are casting the object to a DataTable.
basically it's not context = context , it's context = datatable
 
ProcessRequest is passed the HttpContext object for the current request. This is the same as using System.Web.HttpContext.Current. Pages also expose the context through the Context property. All three of these are the same exact object instance.
 
Back
Top