This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
public:
property System::Security::Principal::IPrincipal ^ User { System::Security::Principal::IPrincipal ^ get(); void set(System::Security::Principal::IPrincipal ^ value); };
public System.Security.Principal.IPrincipal User { get; set; }
member this.User : System.Security.Principal.IPrincipal with get, set
Public Property User As IPrincipal
Property Value
Examples
The following example shows how to access properties of the current user through the
User
property. Those properties are used to set the title of the Web page.
If the application uses Windows authentication, the user name includes the domain. For example, the page title would be "Home page for DOMAIN\username".
protected void Page_Load(object sender, EventArgs e)
if (User.Identity.IsAuthenticated)
Page.Title = "Home page for " + User.Identity.Name;
Page.Title = "Home page for guest user.";
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (User.Identity.IsAuthenticated) Then
Page.Title = "Home page for " + User.Identity.Name
Page.Title = "Home page for guest user."
End If
End Sub
Remarks
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 using the fully qualified class reference to HttpContext. For example, you can use 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 a fully qualified reference to both the currently active request/response context and the class in System.Web that you want to use. For example, in a code-behind page you must specify the fully qualified name HttpContext.Current.User.Identity.Name
.
Using OAuth Providers with MVC 4
Getting Started with ASP.NET 4.5 Web Forms - Checkout and Payment with PayPal
NerdDinner - Secure Applications Using Authentication and Authorization