Login Register
Code2night
  • Home
  • Blog Archive
  • Tutorial
  • Interview Q&A
  • Languages
    • Angular
    • C
    • c#
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • Security
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
    • SEO Analyzer
  1. Home
  2. Blog
  3. Linkedin Sign In using LinkedinLogin Nuget package in Asp-Net MVC

Linkedin Sign In using LinkedinLogin Nuget package in Asp-Net MVC

Date- Jul 05,2022

8800

Free Download Pay & Download
LinkedinLogin LinkedinProfile

Hello guys and welcome to Code2Night! In this article, we'll take a look at how to integrate the Linkedin Sign In functionality using the LinkedinLogin Nuget package in an Asp-Net MVC application.  We'll cover everything you need to know to get up and running with this powerful authentication method, so let's get started!

Web developers are probably well aware of the requirement to integrate social logins into their applications. Users expect to be able to check in with their preferred platforms thanks to the growth of social media, rather than having to create yet another login and password. This enhances the user experience while also making it easier for developers to authenticate users.

One social login that has become increasingly popular is the Linkedin Login. With millions of professionals on the platform, it's a great option for applications targeting the business or career-oriented demographic.

 

Install-Package from Nuget Package Manager

So, we will be using a Nuget package that is used for linkedin login in two easy steps and is quite simple. So first of all you have to install the Nuget package that is shown in the image. 

Nuget Package


You can also install this Nuget package using the command in the package manager console

 Install-Package LinkedinLogin -Version 1.0.0

After you have successfully installed the LinkedinLogin page. You have to go to the controller and add code to your controller.

Now this method will return you the redirect URL which you have to add in your button href on view and on clicking that button it will redirect to the LinkedIn login screen. So we will be storing the information in ViewBag and passing that on to the view. So first do this on the controller side on the action which is fired when the page is loaded.

        public ActionResult Index()
        {
            ViewBag.uri = LinkedinLogin.LinkedinPackage.RedirectToLinkedinLoginUrl("ClientId", "redirectUri");
            ViewBag.url = LinkedinLogin.LinkedinPackage.RedirectToLinkedinLoginUrl("7710pzauu34u5oni12cxsabc", "http://localhost:8080/Home/RedirectLinkedIN");
            return View();
        }

Now, we will add another action method which is the redirect method which we will redirect after you enter your LinkedIn id and password on the LinkedIn login screen and authentication is successful. then it will redirect to the method. You have to pass the URL of this method in redirect uri as a parameter. This must also be added when creating LinkedIn client id and client secret key.

        public ActionResult RedirectLinkedIN(string code)
        {
            try
            {
                var results = LinkedinLogin.LinkedinPackage.GetLinkedinUserProfile(code, "clientId", "clientSecet", "redirectUri");
                var result = LinkedinLogin.LinkedinPackage.GetLinkedinUserProfile(code, "7710pzu5onereeicxs", "xUvKfIranere45Z0KDa50", "http://localhost:8080/Home/RedirectLinkedIN");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return View();
        }

Now, the URL that we set in the viewing in the first step will be used like this on the view. When you will click on this anchor button it will redirect to the LinkedIn Login screen where you will authenticate your user.

 @{
    ViewBag.Title = "Home Page";
}
<a style="margin-top:10px" href="@ViewBag.url"
   class="btn btn-primary"> Hureee!Login with LinkedIN</a>

Now, run the application and you will see this button. Click on this button

You will see this screen on redirect. You can also face an error if Redirect URI in the app doesn't match the one passed in the code. If everything is fine you will see this screen. Enter the details and click on Sign in.

Now, it will redirect to the method which we have passed inside the redirect URI. Here you will get the Code parameter in the request sent by LinkedIn.This code will be passed in our second method along with the client id, client secret, and redirect URI. In the result, you can see the LinkedIn profile returned for the logged-in user.

So this is how you can integrate Linkedin Sign In using the LinkedinLogin Nuget package in Asp-Net MVC. If you face any issue you can comment on the article.

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Linkedin Sign In using LinkedinLogin Nuget package in Asp-Net MVC
Apr 14, 2023
Implement Facebook Login in Asp.Net MVC
Apr 18, 2023
Excel Export in Asp.Net MVC using XlWorkbook
Jun 11, 2022
How to export view as pdf in Asp.Net Core
Jul 05, 2022

Comments

Contents

More in ASP.NET MVC

  • Implement Stripe Payment Gateway In ASP.NET 58610 views
  • Jquery Full Calender Integrated With ASP.NET 39528 views
  • Microsoft Outlook Add Appointment and Get Appointment using … 27456 views
  • How to implement JWT Token Authentication and Validate JWT T… 25158 views
  • Payumoney Integration With Asp.Net MVC 23107 views
View all ASP.NET MVC posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
  • SEO Analyzer
By Language
  • Angular
  • C
  • c#
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page