4

Is there a sample of the Facebook C# SDK with ASP.NET MVC 3 (non-canvas application) that:

  1. Allows the user to register through the website's registration form
  2. Allows the user to login through Facebook Connect, and register the user if it's his/her first visit
  3. Subsequently allow user to login/authenticate through the website's login form, or through Facebook (if the user registered through Facebook Connect).

It seems like this would be a common scenario that would benefit many others, but virtually all the samples I've seen do not go beyond authenticating the user with Facebook. I'm thinking a sample that can perform the basic login/registration scenario would help in not having to re-invent the wheel.

Many thanks! :)

Gerald
  • 71
  • 1
  • 4
  • @moguzalp thanks, but this is what I meant that most examples/samples out there go about as far as that. Perhaps I'll post my own take on a sample once I get round to it. – Gerald Jan 10 '12 at 11:50
  • Just what I need also.. Did you find anything useful in the meantime? – rjovic Jan 16 '12 at 18:38
  • The upcoming MVC 4 will support the new Simple Membership Provider, which handles OAuth and OpenID. It's currently implemented in ASP.NET Web Pages 2 DP (http://www.asp.net/web-pages/overview/what's-new/top-features-in-web-pages-2-developer-preview#oauthsetup) and I (finally) found concrete information that it SHOULD be heading into the upcoming release of MVC 4 (http://aspnet.uservoice.com/forums/41199-general/suggestions/486926-new-membership-provider-interface-supporting-redir). I feel that would make for a better solution than re-inventing the login system so I'll be holding out for that. – Gerald Feb 02 '12 at 07:43

1 Answers1

3

I am currently doing this on my website. However note that the Membership provider does not align properly with FB Authentication. In my project I have 2 controllers one for FB authentication and the other one is for Forms authentication. The Forms Authentication code is pretty much the standard one provided in a new project except that I am encrypting my password with BCrypt after adding a Salt value.

Please refer to my blog http://theocdcoder.com/tutorial-integrating-facebook-authentication-asp-net-mvc-3/ for the FB integration. The reason I didn't include the other Forms code is that it is independent of FB code.

Also in the FB login method in the Controller, you will have to handle the scenario if the user was already registered through Forms method if not then create a new record for the same.

I hope it helps.

Ketan
  • 5,861
  • 3
  • 32
  • 39