Adding OpenID support to your VB.NET web site couldn’t be easier. Here is the easiest way:
- Download the DotNetOpenId library.
- Extract the DotNetOpenId.dll from the bin directory of the .zip file you downloaded.
- Make sure you’re using FormsAuthentication.
- Open Web.config
- Find your <authentication> tag (or create it if you’re sure it doesn’t already exist) and change it if necessary so it looks something like this: (the really important part is just mode="Forms")
<forms defaultUrl="/default.aspx" loginUrl="~/login.aspx"/>
- Add a Reference to DotNetOpenId.dll from your web site.
- Navigate to your Login.aspx page.
- Drag the OpenIdLogin control from your control Toolbox to the location on your page you want it to appear.
NOTE: If the controls do not appear in your Toolbox, follow these steps to add them:
- Right-click somewhere on the Toolbox and click Choose Items… (it can take a while before the dialog shows up)
- In the .NET Framework Components tab, choose Browse.
- Select the DotNetOpenId.dll that you extracted from the zip file.
- Click OK.
- Several controls will get added to your Toolbox. Drag the OpenIdLogin control to your page.
- You should have a couple of new lines in your .aspx file:
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.RelyingParty" TagPrefix="RP" %>
<RP:OpenIdLogin ID="OpenIdLogin1" runat="server" />
- If you’re starting a brand new site and don’t have a way to tell who is logged in on your site yet, go ahead and drag LoginName and LoginStatus controls to some new page that you can use to check your own logged-in status.
- Go ahead and run your app. You’re already done.
Now, this is admittedly the simplest case. If you have an existing userbase with usernames and passwords, you’ll want to build pages to help your users make the transition. You can certainly support dual-mode authentication, but each web site is different and you’ll have to design your own plan for doing that. But if you find you need more flexibility with how the OpenID login control looks or works, check out the OpenIdTextBox control. If there’s demand (leave a comment on this post), I’ll follow up with a post or two on how to customize this.