This documentation is archived and is not being maintained.

HttpContext.User Property

Gets or sets security information for the current HTTP request.

[Visual Basic]
Public Property User As IPrincipal
[C#]
public IPrincipal User {get; set;}
[C++]
public: __property IPrincipal* get_User();
public: __property void set_User(IPrincipal*);
[JScript]
public function get User() : IPrincipal;
public function set User(IPrincipal);

Property Value

Security information for the current HTTP request.

Remarks

Setting this property requires the ControlPrincipal flag to be set in Flags.

The HttpContext.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. If you want to use the members of IPrincipal from an ASP.NET code-behind module, however, you must include a reference to the System.Web namespace in the module and also fully qualify the reference to 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.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpContext Class | HttpContext Members | System.Web Namespace

Show: