Google 2 Step Authenticator – MVC 5.0 ASP.Net C#

Requirement : Implement google 2 step authentication in any existing MVC C# Project. Features : Highly Secure No need of internet to get OTP Code No cost for OTP code unlike SMS No need to wait long to get a code Both IOS and Android are supported Complete solution with source code available for download 30 Days cookie so no need to authenticate daily [Can be changed] Easily add or edit private secure code in web config. Enable 2 step feature from Web.config The session cookie is Encrypted for security purpose Source Code : Download complete source code from my repository: Steps : Create a blank MVC Project Install Google Authenticator from Nuget Package 3. Add New Controller and name as LoginController Copy Below Code to controller using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.Configuration; using System.Web.Mvc; using System.Web.Security; using GAuthenticator.Models; using Google.Authenticator; namespace GAuthenticator.Controllers { public class LoginController : Controller { // GET: Login public ActionResult Index() { return View(); } public ActionResult Login() { return View(); } [HttpPost] public ActionResult Login(LoginModel login) { string message = “”; bool status = false; //check UserName and password form our database here string GAuthPrivKey = WebConfigurationManager.AppSettings[“GAuthPrivateKey”]; […]

» Read more