ASP.NET MVC: Facebook Authentication


Facebook Authentication in ASP.NET MVC

Social media authentication is the one of the major authentication technique in modern websites. Most of the visitors to our website would not like to register on our website. However, they will use their existing social media account to create an account in our website. In this article I will explain the Facebook authentication in ASP.NET MVC.

How to integrate Facebook Authentication in ASP.NET MVC ?

First open the visual studio and create an ASP.NET MVC application . Here I am using Windows Azure to deploy my application. If you are not familiar with Azure deployment, then please read this article Hosting ASP.NET in Azure

ASP.NET - Facebook Authentication - 1

After Azure deployment, go to and click on add a new app button .

ASP.NET - Facebook Authentication - Create app

Once we click on add a new app, it will show a pop up and we need to select the type (iOS , Android , Facebook canvas, website) of app. Choose website from here.

ASP.NET - Facebook Authentication - Select APP

Enter the website name and select category (Education , Entertainment etc)

ASP.NET - Facebook Create app id

Then enter your website URL and click on next button. Now you have created the website on Facebook. Scroll down the page, then you can see the dashboard URL there.

ASP.NET - Facebook Authentication - Enter site address

Click on dashboard URL, then you will get the following screen with the App ID, App Version and App secret. When we click on the show button on App secret, it will ask your Facebook password. After entering the correct Facebook password you can see your App Secret.

ASP.NET - Facebook Authentication - FB Dashboard

Go to your website’s (which is published in Azure) login page . On the right side you can see a section for other login.

ASP.NET - Facebook Authentication - without FB

Go to Startup.Auth.cs class and ether following code inside ConfigureAuth method.

               appId: "875923389195611",
               appSecret: "<Enter your app secret here>");

Publish your app in to Azure. Then check the login page. You can see a Facebook button on right side.

ASP.NET - Facebook Authentication - with FB

Click on the Facebook button. It will redirect to

ASP.NET - Facebook Authentication - next

If you are already logged in, It would not ask the login credentials again. You will get the preceding screen and click Okay . Now the user is authentic and it will redirect to your website.

The following two tabs change content below.

Tom Mohan

Tom Mohan is a technologist who loves to code and build. He enjoys working on Microsoft Technologies. Tom specializes in ASP.NET MVC, Web API , Azure, C# ,WPF, SQL etc and holds a Bachelor engineering degree in Computer Science. Certification : MCSD , MCTS

Latest posts by Tom Mohan (see all)