Gerald
Gerald

Reputation: 71

Facebook C# SDK sample for user account registration in ASP.NET MVC 3

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! :)

Upvotes: 4

Views: 4129

Answers (1)

Ketan
Ketan

Reputation: 5891

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.

Upvotes: 3

Related Questions