Friday, October 09, 2009

VS2008 project template for OpenID and InfoCard relying parties

I finally built a project template to make it easier to write an OpenID relying party web site using C# and ASP.NET.  Up to this point all we had were the sample RPs that ship with DotNetOpenAuth, which were deliberately kept simple.  They didn’t use a real database, didn’t follow some best practices, and weren’t very real. 

Now you can start your next web site with OpenID and InfoCard logins already working!  Complete with role authorization, account management that allow for multiple OpenID/InfoCards per account, login and account creation.

And did I mention it’s free? (donations gratefully accepted)

Download it and copy the file "Project Templates\*.vsi" file into your %USERPROFILE%\Documents\Visual Studio 2008\Templates\ProjectTemplates folder and it will appear in your New Project wizard in Visual Studio 2008.

Yes, the site is still unbeautified, but that’s so you can brand it to look like yours.

Have fun.  And let me know what you think of it or can contribute.


  1. Lets say I have two Google accounts (G1 and G2).

    I login to your sample website (running on my PC) as G1 and then logout again.

    I now want to login as G2. SO I try and login again, but when I click Google on the sample website it logs me in automatically (without giving an opportunity to choose G2).

    Is this an intrinsic limitation of OpenId (ala )?

    If so, how does rpxnow work? When you logout on rpxnow's website and then login again, it remembers your last login but has 'This isn't me' to allow you to switch to a different Google account. Are there any .Net OpenID samples showing how this could be achieved?

  2. Hi,

    That's a very interesting scenario. It will work at any RP (RPXNow, DotNetOpenAuth, or other) until you click "Remember me" at Google while logging into a given RP. After which, Google will never intercept the login to the RP again, thereby not giving you the chance to choose to switch to G2.

    At least from my testing just now that seems to be the case.

    So if you really want to do this, it looks like the only way is to actually log out of your G1 account at Google first, and then try logging into the RP, which will then send you to Google where you can choose to log in as G1 or G2.

  3. Firstly, thank you for all your hard work on this. I'm still trying to get my head around the OpenID thing, and hopefully this will make life easier.

    Just as a suggestion, it might help to create a vsi file to distribute your template, as described here:

    I stupidly unzipped it at first, then spent ages trying to figure out why it didn't like $safeprojectname$ - entirely my fault, but an installer file would make the process a bit more obvious to a doofus like me :)

    Also, I'm using the Express version of Visual Studio at the moment. When I installed Visual Web Developer 2008, it complained about SQL 2005, so I had to upgrade that to SQL 2008. (I'm not sure whether this is a new requirement for SP1.) Unfortunately, that means that the SQL references in your project template don't work, since they're looking for v9 files, so I had to remove them and add the corresponding v10 references. Again, not a huge issue, but if most people have SQL 2008 installed then it might be worth updating the template.

  4. Hi Andres,
    Firstly amazing work by you !
    Secondly I am trying to use open Auth for VS 2008 and not able to get the version required. In the website I foung 3.4.6 with some samples but they work for VS 2010. What would be the version for 2008? Can u please point me to the proper Version for 2008 and also the samples for 2008? Your help is greatly appreciated.
    Thanks a ton!

  5. Thank you, the template is great.

    While I am trying to understand how to leverage DNOA, I bump into a few problem.

    I thought I was able to use DNOA just by adding reference to .dll. or is it?

    Could you please give me some guideline on the template, thanks in advance.
    1. Is RelyingPartyLogic handling only the persistent layer for managing token/secret?
    2. Should I implement my own RelyingPartyLogic so that I can use my database which reside on my SQL server?

  6. Maxi Ng,

    Adding the dotnetopenauth.dll reference to your web site is the first step. You have to wire it up using either your code behind or an ASP.NET control, which is easy. These project templates are designed to get you going with a production-quality web site out of the gate, including database persistence and best practices. If you already have a database, adjust RelyingPartyLogic to suit your needs.

  7. Hi, i am very interested in this project, i would really like to see that code. Please the link isn't working, could you fix it?.

    I'll really appreciate it.

    PD: thanks for your work, u are one in a million.

  8. elRuLL, I've fixed it. Thanks for pointing it out.