Using IDLoginView with IDLogin Windows Live Control

The IDLoginView control shipped with the Windows Live Tools control is a pretty good control for developers who want to customize the web page look depending on the Sign In status of the user. Normally, you would use a Login control on the page and once signed in with it, you could write a piece of code to display some items on the page which you want to display only to Windows Live Signed In users. Even more, if you plan to use ASP.NET Forms authentication for your website and customize the display for the users after being authenticated with it, you would write your own code to display them. IDLoginView control takes a step ahead and makes it way easy for the developer to assign templates depending on the status of the user visiting the page.

The IDLoginView control has 5 templates defined as follows:

  • Anonymous : Not signed in Windows Live and not authenticated by ASP.NET website
  • Loggedin : Authenticated by ASP.NET but not signed in Windows Live.
  • LoggedInId : Signed in Windows Live
  • LoggedInAll : Signed in Windows Live and ASP.NET website.
  • AssociatePrompt : A template used to prompt the user to associate the windows live ID with the ASP.NET user account.

The templates are self-defined here but the interesting one is the Associate Prompt. This prompt if defined for the control, will prompt the user whether to create an association between their windows live account and ASP.NTE website account. Of course for this template to appear one has to create a website account using the ASP.NET security configuration. Once an association is created, any time later if the user signs in Windows Live they will be automatically authenticated for the ASP.NET website.

Follow the following simple steps to use these controls on your page.

  • Drag a IDLoginView control on the page. In the designer view, click the small arrow button over the control to view all the templates.
  • Drag a ASP.NET Login control and the IDLogin control in this template.
  • Since you would need to see the status of the user all the time, copy these Login and IDLogin control in all the templates.
  • The AssociatePrompt template displays a message with Yes and No buttons. You could change this template as you want, but make sure that there is a button which has a command name as associate_yes and another button with a command name as associate_no.

You could test your application by running the website and signing in Live and ASP.NET website. The prompt appears when you are signed in one of the accounts and then sign in the other account. To this to work you need the PromptOnAssociation to true.

Internally when you give an affirmative response to the prompt, a single row is added in the aspnet_LiveIDAssociation table in ASPNETDB database. You can see this database if you do show all files for the project. If you no longer want this association to take place delete this row from the table, for now, there is no UI to remove the association for the control.

I avoided thorough details about the control since you can find them here.

Cannot Open User Default database Error.

Bug: If you open the table to view the association entry, and then again try running the website you might get an error like Login failed for the default user. This bug is been posted on ASP.NET forums and many other places. I tried closing the IDE and reopening it. The website works, I think this is a bug with the SQL express since when it is open in the IDE, the error appears.

Abhang Rane


No comments :

Post a Comment

Leave a Comment...