Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HttpContext.User Property

Gets or sets security information for the current HTTP request.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public IPrincipal User { get; set; }
/** @property */
public IPrincipal get_User ()

/** @property */
public void set_User (IPrincipal value)

public function get User () : IPrincipal

public function set User (value : IPrincipal)

Property Value

Security information for the current HTTP request.

Setting the User property requires the ControlPrincipal flag to be set.

The User property provides programmatic access to the properties and methods of the IPrincipal interface. Because ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without the fully qualified class reference to HttpContext. For example, you can use just User.Identity.Name to get the name of the user on whose behalf the current process is running. However, if you want to use the members of IPrincipal from an ASP.NET code-behind module, you must include a reference to the System.Web namespace in the module and also fully qualify the reference to both the currently active request/response context and the class in System.Web you want to use. For example, in a code-behind page you must specify the full name HttpContext.Current.User.Identity.Name.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft