Provides data for the CreatingCookie event.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Gets or sets a value that indicates whether the authentication cookie has been created.
Gets additional authentication values that are provided by the user.
Gets a value that indicates whether the authentication cookie should be retained beyond the current session.
Gets the password for the user.
Gets the name for the user.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
The CreatingCookie event handler. By using the properties of this class, you can retrieve user credentials when you create a custom authentication cookie.class supplies values to any
The AuthenticationService class raises the CreatingCookie event when it sets the authentication cookie, after the user credentials have been authenticated. The AuthenticationService class constructs a object and passes it to any CreatingCookie event handler.
You retrieve the user credentials through the UserNamePassword, and CustomCredential properties. The CustomCredential property can contain any custom values that you need in order to authenticate, such as an identification number. The IsPersistent property indicates whether the authentication cookie should be retained past the current session. Set the CookieIsSet property to true if you create the authentication cookie, so that the AuthenticationService class does not create the cookie.
The following example shows an event handler for the CreatingCookie event. The handler retrieves user values from the object to customize the authentication cookie. The handler saves the value from the CustomCredential property in the authentication ticket and sets the CookieIsSet property to true to indicate that the authentication cookie has been created.
Sub AuthenticationService_CreatingCookie(ByVal sender As Object, _ ByVal e As System.Web.ApplicationServices.CreatingCookieEventArgs) Dim ticket As FormsAuthenticationTicket = New _ FormsAuthenticationTicket _ (1, _ e.Username, _ DateTime.Now, _ DateTime.Now.AddMinutes(30), _ e.IsPersistent, _ e.CustomCredential, _ FormsAuthentication.FormsCookiePath) Dim encryptedTicket As String = FormsAuthentication.Encrypt(ticket) Dim cookie As HttpCookie = New _ HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) cookie.Expires = DateTime.Now.AddMinutes(30) HttpContext.Current.Response.Cookies.Add(cookie) e.CookieIsSet = True End Sub
Available since 3.5
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.