System.Web (system.web.dll)sealed class

The HttpContext class represents the "operating context" of an ASP.NET application. It provides references to instances of fundamental classes like HttpApplicationState and HttpRequest, which are known as intrinsic or "built-in" objects. The HttpContext class is provided to IHttpModule and IHttpHandler instances (like System.Web.UI.Page and HttpApplication), which provide these classes through their own properties. The shared (static) property Current returns the current HttpContext, and is useful if you need to access the built-in ASP.NET objects from another code module like a class (where you won't have access to the System.Web.UI.Page properties). One example is a web service that doesn't inherit from System.Web.Services.WebService. You can also use the shared GetAppConfig( ) method to retrieve a collection object from the web.config file that contains configuration information. Just specify the configuration section you want to examine as a parameter (like "appSettings").

If you are creating your own IHttpHandler class, you will receive the current instance of the HttpContext class as a parameter of the IHttpHandler.ProcessRequest( ) method. To use the Session property of the HttpContext class, you must also implement either the System.Web.SessionState.IReadOnlySessionState interface or the System.Web.SessionState.IRequiresSessionState interface.

public sealed class HttpContext : IServiceProvider {
// Public Constructors
   public HttpContext(HttpRequest request, HttpResponse response);
   public HttpContext(HttpWorkerRequest wr);
// Public Static Properties
   public static HttpContext Current{set; get; }
// Public Instance Properties
   public Exception[ ] AllErrors{get; }
   public HttpApplicationState Application{get; }
   public HttpApplication ApplicationInstance{set; get; }
   public Cache Cache{get; }
   public Exception Error{get; }
   public IHttpHandler Handler{set; get; }
   public bool IsCustomErrorEnabled{get; }
   public bool IsDebuggingEnabled{get; }
   public IDictionary Items{get; }
   public HttpRequest Request{get; }
   public HttpResponse Response{get; }
   public HttpServerUtility Server{get; }
   public HttpSessionState Session{get; }
   public bool SkipAuthorization{set; get; }
   public DateTime Timestamp{get; }
   public TraceContext Trace{get; }
   public IPrincipal User{set; get; }
// Public Static Methods
   public static object GetAppConfig(string name);
// Public Instance Methods
   public void AddError(Exception errorInfo);
   public void ClearError( );
   public object GetConfig(string name);
   public void RewritePath(string path);
   public void RewritePath(string filePath, string pathInfo, string queryString);

Returned By

HttpApplication.Context, System.Web.Security.DefaultAuthenticationEventArgs.Context, System.Web.Security.FormsAuthenticationEventArgs.Context, System.Web.Security.PassportAuthenticationEventArgs.Context, System.Web.Security.WindowsAuthenticationEventArgs.Context, System.Web.Services.WebService.Context, System.Web.UI.Control.Context

Passed To

Multiple types

    Part I: Introduction to ASP.NET
    Part III: Namespace Reference
    Chapter 40. The System.Web.UI.MobileControls Namespace
    Chapter 42. The System.Web.UI.WebControls Namespace