Click here to Skip to main content
15,891,513 members
Articles / Web Development / ASP.NET

OpenID With Forms Authentication

Rate me:
Please Sign up or sign in to vote.
4.96/5 (72 votes)
13 Dec 2010CPOL14 min read 356.7K   5.5K   168  
Shows how to use OpenID with ASP.NET MVC Forms Authentication.
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>OpenId Demo</title>
    <link rel="stylesheet" type="text/css" media="screen" href="../../Content/openid.css" />
    <script type="text/javascript" src="../../Scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.openid.js"></script>
    <script type="text/javascript">        $(function () { $("form.openid:eq(0)").openid(); });</script>
</head>
<body>
    <div>
        <h2>
            Logon Using OpenId</h2>
        <p>
            <%=ViewData["message"]%></p>
        <form class="openid" method="post" action="/Account/Logon">
        <div>
            <ul class="providers">
                <li class="openid" title="OpenID">
                    <img src="../../Content/images/openidW.png" alt="icon" />
                    <span><strong>http://{your-openid-url}</strong></span></li>
                <li class="direct" title="Google">
                    <img src="../../Content/images/googleW.png" alt="icon" />
                    <span>https://www.google.com/accounts/o8/id</span></li>
                <li class="direct" title="Yahoo">
                    <img src="../../Content/images/yahooW.png" alt="icon" />
                    <span>http://yahoo.com/</span></li>
                <li class="username" title="AOL screen name">
                    <img src="../../Content/images/aolW.png" alt="icon" />
                    <span>http://openid.aol.com/<strong>username</strong></span></li>
                <li class="username" title="MyOpenID user name">
                    <img src="../../Content/images/myopenid.png" alt="icon" />
                        <span>http://<strong>username</strong>.myopenid.com/</span></li>
                <li class="username" title="Flickr user name">
                    <img src="../../Content/images/flickr.png" alt="icon" />
                        <span>http://flickr.com/<strong>username</strong>/</span></li>
                <li class="username" title="Technorati user name">
                    <img src="../../Content/images/technorati.png" alt="icon" />
                        <span>http://technorati.com/people/technorati/<strong>username</strong>/</span></li>
                <li class="username" title="Wordpress blog name">
                    <img src="../../Content/images/wordpress.png" alt="icon" />
                        <span>http://<strong>username</strong>.wordpress.com</span></li>
                <li class="username" title="Blogger blog name">
                    <img src="../../Content/images/blogger.png" alt="icon" />
                        <span>http://<strong>username</strong>.blogspot.com/</span></li>
                <li class="username" title="LiveJournal blog name">
                    <img src="../../Content/images/livejournal.png" alt="icon" />
                        <span>http://<strong>username</strong>.livejournal.com</span></li>
                <li class="username" title="ClaimID user name">
                    <img src="../../Content/images/claimid.png" alt="icon" />
                        <span>http://claimid.com/<strong>username</strong></span></li>
                <li class="username" title="Vidoop user name">
                    <img src="../../Content/images/vidoop.png" alt="icon" />
                        <span>http://<strong>username</strong>.myvidoop.com/</span></li>
                <li class="username" title="Verisign user name">
                    <img src="../../Content/images/verisign.png" alt="icon" />
                        <span>http://<strong>username</strong>.pip.verisignlabs.com/</span></li>
            </ul>
        </div>
        <fieldset>
            <label for="openid_username">
                Enter your <span>Provider user name</span></label>
            <div>
                <span></span>
                <input type="text" name="openid_username" /><span></span>
                <input type="submit" value="Login" /></div>
        </fieldset>
        <fieldset>
            <label for="openid_identifier">
                Enter your <a class="openid_logo" href="http://openid.net">OpenID</a></label>
            <div>
                <input type="text" name="openid_identifier" />
                <input type="submit" value="Login" /></div>
        </fieldset>
        </form>
    </div>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.

Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

Comments and Discussions