UWP vs WPF - Key Differences Explained!
Several experts, particularly those just starting out, often find themselves confused about WPF and UWP, wondering if they are the same. Since they are used to create great UIs for...
Kapil Panchal - July 15, 2021
Listening is fun too.
Straighten your back and cherish with coffee - PLAY !
Two-factor authentication (2FA) is an excellent way to enhance both the robustness of your authentication system and the user experience with your authentication process. 2FA adds something that a user has to what he knows in the process of checking what he tells himself to be.
Safety is important, just ask any blue check Twitter user. Deploying your own authentication system is time-consuming and involves numerous risks. So, how do you get beyond user identifiers that are nothing more than an email address and a password that is lengthy and probably difficult to remember if it is correct.
Let’s discuss how to build an app with SMS and email 2FA Two-factor authentication in Asp.Net MVC –
This gives advice on how to use Twilio or ASPSMS, but you can use any other SMS provider.
Create a user account with an SMS service provider.
Installation of additional packages or addition of service part numbers.
This provides instructions on how to use Twilio or ASPSMS, however, you can use any other SMS provider.
The following service reference must be included:
https://webservice.aspsms.com/aspsmsx2.asmx?WSDL
ASPSMSX2
From your Twilio Account's Dashboard tab, copy the Account DIS and Auth Token.
In the settings of your account, navigate to Userkey and copy with your password set by yourself.
We shall subsequently store these values on the web. config file by pressing "SMSAccountIdentification" and "SMSAccountPassword".
Under the Numbers tab, copy your Twilio telephone number.
On the Unlock Initiators menu, unlock one or more Initiators or select an Alphanumeric Initiator (not supported by all networks).
We will later store this value on the web. config file within the key "SMSAccountFrom".
Make the sender's identification and telephone number available to the application. To keep things simple, we're going to store those values in the web. config file. When we deploy Azure, we can safely store the values in the application settings section on the website configuration tab.
Configuring the SmsService class in the App_Start IdentityConfig.cs
According to the SMS provider used, enable the Twilio or ASPSMS section:
public class SmsService : IIdentityMessageService { public Task SendAsync(IdentityMessage message) { } }
(note: do not only delete comments from the outgoing code but also use the code below.)
@model MvcPWy.Models.IndexViewModel @{ ViewBag.Title = "Manage"; }
Check whether the EnableTwoFactorAuthentication and DisableTwoFactorAuthentication action methods in the ManageController have the attribute[ValidateAntiForgeryToken]:
[HttpPost,ValidateAntiForgeryToken] public async TaskEnableTwoFactorAuthentication() { await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), true); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInAsync(user, isPersistent: false); } return RedirectToAction("Index", "Manage"); } [HttpPost, ValidateAntiForgeryToken] public async Task DisableTwoFactorAuthentication() { await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), false); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInAsync(user, isPersistent: false); } return RedirectToAction("Index", "Manage"); }
public ActionResult AddPhoneNumber() { return View(); }
By clicking on the “Remember this browser” checkbox, you will not have to use 2FA to sign in when you use the browser and the device in which you checked the checkbox. Until malicious users can access your device, enable 2FA and click Remember this browser will provide you with convenient password access in a single step, while maintaining a high 2FA protection for all access from unsecured devices.
In this blog, we learned how to activate 2FA on a new ASP.NET MVC application. We have also gone through Two-factor authentication by text message and e-mail with ASP.NET Identity details with the code behind the sample.
Build Your Agile Team
Several experts, particularly those just starting out, often find themselves confused about WPF and UWP, wondering if they are the same. Since they are used to create great UIs for...
Many companies rely on advanced technologies to make informed decisions in their business. For instance, some Chief Technology Officers (CTOs) turn to Power BI consulting services,...
Importance of C# - custom software development C# has been dominating the world of programming for the last two decades. Did you know it is the favored language of about 31% of...