How to show Hide login and logout link on the basis of user login or not in asp.net core?

Asp.net-core By Sagar Jaybhay

Show Hide Login Logout Link on basis of user login or not To perform login and logout we use the SignInManager class in asp .net core identity. We have to add a logout functionality button in the layout view so we need to insert SignInManager instance into _Layout view by using dependency injection. To insert instance in layout or razor view we use @inject Need to add this _Layout view. But we need to move using statement in a central file which is ViewImport file and we add this using…

Read More

How to Customize default password complexity rules in asp.net core?

Asp.net-core By Sagar Jaybhay

Asp.net core never allows you to create a simple password because it is easily crack able and also to restrict brute force attacks. Suppose you enter some simple password like abcd it will throw an error. Passwords must be at least 6 characters. Passwords must have at least one non alphanumeric character. Passwords must have at least one digit (‘0’-‘9’). Passwords must have at least one uppercase (‘A’-‘Z’). Check this link:- https://github.com/aspnet/AspNetCore/blob/master/src/Identity/Extensions.Core/src/PasswordOptions.cs So if want to change this default behavior you need to do these changes in configure service method…

Read More

How to use UserManager and SignInManager in Asp.net

Asp.net-core By Sagar Jaybhay

UserManager and SignInManager in Asp.Net Core Identity Asp.net core provides two important services. UserManager SignInManager The above 2 services are used to create users, validate the user and then add it to the database. These are 2 core services of Identity framework. To use these services we need to inject these services in the controller and we inject this in the constructor like below. UserManager: This user manager took one generic parameter which is IdentityUser. UserManager has following methods CreateAsync DeleteAsync UpdateAsync Etc… SignInManager: This also takes a generic parameter…

Read More

How to register new User Using Asp.net core Identity?

Asp.net-core By Sagar Jaybhay

Asp.net core Identity Part 1 For registration of the new user, you need to create a ViewModel class for that. We have created RegistrationViewModel class in our application. In this class, we use a built-in validation attribute. These are present in System.ComponentModel.DataAnnotations namespace and for another EmailAddress attribute we used which is used for the validate the email address. Similarly, for the password we used Password which is used when we type password on UI then masking is done. After that, we added the Registration controller and in that we…

Read More

Simple Identity In Asp.Net Core Tutorial from scratch part 1

Asp.net-core By Sagar Jaybhay

Asp.net core Identity used for a security-related feature in your asp.net core application. Asp.net core identity is a membership system that adds a login functionality to our app. It is a built-in membership system. Uses of Asp.net core Identity Is used to create, update, read and delete user accounts Authentication and authorization Is also used for password recovery Two-factor authentication with SMS Asp.net core Identity supports external login like Facebook, Google and Microsoft Steps for Identity In Asp.Net Core Step 1 Need to add IdentityDBContext instead of DbContext means In…

Read More