Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>an <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.iprincipal.aspx" rel="noreferrer"><code>IPrincipal</code></a> is the security context which is created for each web request and contains information related to the identity of the user and roles that they have.</p> <p>an <code>IPrincipal</code> contains an <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.iidentity.aspx" rel="noreferrer"><code>IIdentity</code></a> that has a <code>Name</code>, an <code>IsAuthenticated</code> and <code>AuthenticationType</code> properties.</p> <p>a custom <code>MembershipProvider</code> is a class that derives from the abstract class <code>MembershipProvider</code> to provide custom data about users who use your application. The provider will operate on <a href="http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.aspx" rel="noreferrer"><code>MembershipUser</code></a> types and can be used to get data for a particular user or users, create new users, etc. You can inherit from <code>MembershipUser</code> to create your own user type and may typically want to do this when also using your own provider.</p> <p>When you access an application, an <code>IPrincipal</code> and <code>IIdentity</code> are created and assigned to <a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx" rel="noreferrer"><code>HttpContext.Current.User</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.currentprincipal.aspx" rel="noreferrer"><code>Thread.CurrentPrincipal</code></a> to provide security information for any action that may be taken during the lifetime of the request.</p> <p>If you're using a <code>RoleProvider</code>, then a <a href="http://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.aspx" rel="noreferrer"><code>RolePrincipal</code></a> type instance is created which hooks into the configured <code>RoleProvider</code> to get roles for the user; if you're not using a <code>RoleProvider</code> then a <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.genericprincipal.aspx" rel="noreferrer"><code>GenericPrincipal</code></a> type instance is created.</p> <p>If you're using forms authentication and a user is logged in, then a <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsidentity.aspx" rel="noreferrer"><code>FormsIdentity</code></a> type instance is created; if a user is not authenticated then a <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.genericidentity.aspx" rel="noreferrer"><code>GenericIdentity</code></a> type instance is created. The <code>IIdentity</code> that is created is what ultimately will be serialized into the authentication cookie passed back to the browser and what will be used to construct the <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx" rel="noreferrer"><code>FormsAuthenticationTicket</code></a> and the <code>IIdentity</code> on the next request.</p> <p>The <code>MembershipProvider</code> fits into this by providing additional information about the user. the static <a href="http://msdn.microsoft.com/en-us/library/system.web.security.membership.aspx" rel="noreferrer"><code>Membership</code></a> class's <a href="http://msdn.microsoft.com/en-us/library/fcxcb339.aspx" rel="noreferrer"><code>GetUser()</code></a> method will use the current <code>IIdentity.Name</code> and the configured <code>MembershipProvider</code> to return an instance of <code>MembershipUser</code> (or derived class if you've defined one) containing the data about the user.</p> <p>Since ASP.NET MVC is built on top of the ASP.NET processing pipeline, the place where you would want to set your own <code>IIdentity</code> and <code>IPrincipal</code> is the same. As far as I know, there is no better place in the MVC architecture to set them.</p> <p><em>Note: this is all from memory. If I have got something wrong, please let me know and I will update.</em> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload