OpenID Implementation In C# & ASP.NET

Thursday, January 24, 2008 by Mistlee


C Programming Tutorials and advice
CProgrammingTrends News Archives About Us Feedback

Recent Articles

IDataRecord Fields To Dictionary Extension Method
I have never been a fan of directly passing IDataRecords, or IDataReaders for that matter, about the place to get simple field values out. herefore, with the introduction of C# 3.0 and Extension Methods, I thought it would...

ECMAScript, The New C++?
Everything but a call for a kitchen sink subroutine has been tossed into ECMAScript 4, leaving a couple of bloggers wondering why. ECMAScript has appeal...

Responses To Microsoft Releasing .NET 3.5 Source
So far the views from Dave, whurley, Matt and others have been negative to handle with caution. After I heard that Microsoft was releasing the .NET 3.5 source...

Resolve & Shorten URLs In C#
Recently I've needed a method that would look at some text and automatically discover all URLs and turn them into hyperlinks. I've done that before so it was a matter of copy/paste. This time it was a little more...

Yahoo SiteExplorer API With C#
If you are interested in using Yahoo's SiteExplorer API and are coding in the ASP.NET environment using C# (web pages) then the following method might be of...

Debug JavaScript In Visual Studio 2005 Like C#
I've been using Visual Studio 2005 for almost 2½ years since the beta 1 release. In all that time, I've used Firefox and Firebug for all JavaScript debugging. I've tried setting breakpoints in JavaScript in Visual...

From VB.NET To C#
Coming from the Visual Basic world, I used to find many examples throughout the web written in VB and VB.NET. Then I got hired by Traceworks which was a VB.NET Then I got hired by Traceworks which was a VB.NET company...


01.24.08

OpenID Implementation In C# & ASP.NET


By Mads Kristensen

Over the weekend I began looking more deeply into OpenID than I have before.

I've always been intrigued by OpenID, but the information about it in terms of code samples in .NET have not been impressive. There are a few projects here and there but they all use a library for handling communication with the OpenID providers.

What I wanted was some code that demonstrated how it works. Not a pre-packaged library to code against. No, I wanted to see how the mechanisms worked so I could try it out in real life with my own code. After searching the web for hours, I finally gave up and started to look at the specs so I could write it myself from scratch. The specs are really hard to understand in terms of actual implementation. They say nothing about protocols and formats, which make it pretty hard to grasp.

After a few ours of hitting the wall with the specs in my hand, I finally found this CodePlex project that was abandoned in July 2007. For some reason, this particular project didn't show up in Google, but I found it by searching the CodePlex site. It made it much easier to understand the mechanisms involved, but it was far from finished and way too complex for what it was trying to solve.

Try a Better Way Today. Try WebEx PCNow

What is OpenID

If you don't know what OpenID is, then take a look at this short video that explains it very well.


The goal

My goal was simple. I wanted to be able to add support for OpenID authentication on existing websites. It means that I wanted to use a standard textbox for entering the OpenID into and a button that would start the whole authentication mechanism. In order to do that, I needed a class that would take care of the communication with the OpenID servers and handle the authentication for me.

So, I ended up with a single small class that can be dumped into any ASP.NET website. It handles the redirection to the OpenID provider and leaves the authentication handling up to the website, but provides all the relevant information for doing so. The class is called OpenID and is very short and simple.

Code example

If you don't care about the code, but still wants to see how this baby works, check out my OpenID video. You can also download the small code sample at the bottom of the post.

Continue reading this article.

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About CProgrammingTrends
A collection of articles and tutorials designed to help C and C variant programmers in their programming work. C Programming Tutorials and advice

CProgrammingTrends is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagmentNews.com


About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact

0 comments: