IDLoginView Control Reference
The IDLoginView control extends the functionality of the ASP.NET LoginView control by adding support for Windows Live ID authentication. It allows you to associate a Windows Live ID with an ASP.NET membership profile and provide a single sign-on experience for your Web site users. It adds new templates to provide richness in your Web site based on the login state of the user.
Similar to the IDLogin control, when you drag and drop the IDLoginView control from the toolbox to your Web page in designer view, the IDLoginView control adds wll_appid and wll_secret keys to the <appSettings> section of the web.config file for your project.
The IDLoginView Control allows you to display different information to anonymous and logged-in users with ASP.NET membership profiles, Windows Live ID, or both. The control displays one of the five templates: AnonymousTemplate, LoggedInTemplate, LoggedInIDTemplate, LoggedInAllTemplate or AssociatePromptTemplate. In the templates, you can markup and control the display information appropriate for anonymous or authenticated users (either ASP.NET membership, Windows Live ID, or both).
IDLoginView Templates
The different templates provided by the IDLoginView control are listed below.
| Template | Description |
| AnonymousTemplate | Specifies the template to display to users who are not logged into the Web site. |
| LoggedInTemplate | Specifies the default template to display to users who are logged in with an ASP.NET membership profile. |
| LoggedInIDTemplate | Specifies the template to display to users who are logged in with Windows Live ID. |
| LoggedInAllTemplate | Specifies the template to display to users who are logged in with both an ASP.NET membership profile and Windows Live ID. |
| AssociateTemplate | Specifies the template to display to users who have not associated their ASP.NET membership profile with their Windows Live ID. |
IDLoginView properties
| Property | Description |
| ApplicationIDConfigKey | Required Name of the <appSettings> key that contains the value of the Application ID for your application. Default value set by control is wll_appid. |
| ApplicationSecretConfigKey | Required Name of the <appSettings> key that contains the value of the Application Secret for your application. Default value set by control is wll_secret. |
| AutomaticallyAssociateAuthentication | Boolean. When true, the control prompts the user to associate their Windows Live ID with an ASP.NET membership profile. The user needs to authenticate on both of these authenitication mechanisms prior to getting this automated experience. The default value for this property is set to true. |
| AutomaticallyConvertAuthentication | Boolean. Controls the behavior of a single sign on experience for the user. When set to true, IDLoginView control attempts to convert a Windows Live ID authentication to an ASP.NET membership authentication using FormsAuthentication.SetAuthCookie. Default value for this property is true |
| PromptOnAssociation | Boolean If the PromptOnAssociation property is set to true, IDLoginView displays AssociateTemplate and prompts the user to associate their Windows Live ID with your Web site’s ASP.NET membership profile. If PromptOnAssociation property is set to false, IDLoginView control automatically associates the ASP.NET membership profile with Windows Live ID behind the scenes. |
IDLoginView Methods
GetAssociatedAuthentication
This assumes the Windows Live ID authentication is completed, and retrieves the ASP.Net membership user if there is an association.
| Return Values | Description |
| String | The ASP.NET membership user to which the Windows Live ID authentication is associated with. |
| String.Empty | When no association exists with the logged on Windows Live ID. |
| Exception | Description |
| InvalidOperationException | When this method call is made without user having authenticated with a Windows Live ID |
AssociateAuthentication (string membershipUser)
Associates the Windows Live ID user with the ASP.NET membership user. Assumes that Windows Live ID authentication is completed and that the user is logged onto the Web site’s ASP.NET membership.
| Argument | Description |
| membershipUser | string The ASP.NET membership user. If an association is already in ASPNETDB.mdf, this is overwritten by this new user |
| Exception | Description |
| InvalidOperationException | When this method call is made without user having authenticated with Windows Live ID |
The IDLoginView control also includes events for ViewChanging and ViewChange, similar to the LoginView Control, which allows you to write handlers for when the user logs in and changes status.