[9/28/07: Update: this control is now being hosted as part of the dotnetopenid project on Google Code]
OpenID is gaining ground, and with good reason. A cross-platform, cross-browser single Internet sign-on using a distributed network is very appealing. I’ll assume though that you already know what OpenID is and why it is a good choice for your web site. This post is about how to add support for OpenID to your web site very easily.
Most of the ease is attributable to the work of Grant Monroe (I believe) due to his work on the .NET implementation of OpenID. While his library seems to be functional, it leaves some to be desired when it comes to actually using it on your site. The steps he uses includes adding several lines to your Web.config file, adding a special .ashx handler class to your web project, and grabbing any request ending in login.aspx regardless of whether and which login page it is on your site.
I was able to leverage his library (written in Boo) with a C# library of my own to put a nice custom web control frontend on his OpenID implementation. Now, aside from adding the library to your web site’s Bin directory, all you have to do is add these two lines to your login page:
<%@ Register Assembly="NerdBank.Tools" Namespace="NerdBank.Tools.WebControls" TagPrefix="nb" %> <nb:OpenIdLogin ID="openIdLogin" runat="server" />
Not bad, eh? All you need before you add these lines is to drop in a compiled version of NerdBank.Tools.dll and its dependencies. You can download a drop, or download the source using Subversion. Both Janrain.dll and NerdBank.Tools.dll are licensed under the LGPL.
If you try this and find you want more control over the appearance than what the OpenIdLogin control offers, use the OpenIdTextBox control, which provides a barebones but fully functional control that does the same thing so you have more control over the UI.
Being that Janrain.dll (where OpenID is implemented) is written in Boo, with which I am not too familiar, I added my custom web control to my own existing C# tools library. Ideally Janrain’s author can take my code and rewrite it in Boo so that it can be all in one assembly for convenience, but I don’t see two assemblies as a big deal in the meantime. In order for my strong-named NerdBank.Tools assembly to reference Janrain.dll, I had to recompile Janrain.dll with a strong name. Other than that it’s the original assembly as I downloaded it from its original site.
The Janrain implementation does not provide (as far as I can tell) for requesting user details during the login process, as the OpenID specification allows for. I also use Janrain’s Ruby implementation of OpenID, which does provide this behavior, so I’m going to investigate this more and either contribute to his project or figure out how to use the feature and build it into my OpenIdLogin control so you can just set properties and they are delivered to you in the OpenIdLogin.OnLoggedIn event. I’ll report via another post on this blog on my progress.
I’d love to download your OpenID control but both download links fail.
try here http://code.google.com/p/dotnetopenid/downloads/list
How about an update on how to use the latest version of the code? You reference NerdBank.Tools.dll but it’s not available anywhere. I’m interested in the whole OpenID thing, but I need a good code sample.
Mike,
Check out the update at the top of the post. There’s a link to a more recent version of the controls. The dependency on Nerdbank.Tools.dll has been removed as well.
hi Andrew!
where can I download source code of ur ASP.NET Login control?
Thank you!
Nice work Andrew!
Nice Post
Informative and useful one
I am .Net Developer and I am looking for this
Thanks for the great stuff.
Nimesh
The steps he uses includes adding several lines to your Web.config file, adding a special .ashx handler class to your web project.
i want asp.net code for how to retrieve user details.. please help me
thank you..
Thanks for sharing such a knowledgeable information on enabling OpenID logins. Is there any type of code in PHP development as well?