How do I setup ASP.NET Identity 2.0 to use my own connection string

By default ASP.NET Identity 2.0 creates the database inside the App_Data directory of the application. ASP.NET identity 2.0 works on the Entity Framework Code First approach and it reads the connection string mentioned in the web.config as shown below, In the ApplicationDbContext class you can find that connection string named DefaultConnection has been used. You … Continue reading How do I setup ASP.NET Identity 2.0 to use my own connection string

Check User exists in a Role in ASP.NET Identity 2.0

Read full post on Falafel blog ASP.NET MVC5 uses Identity 2.0 to manage the users and their roles. There may be scenario to check whether the currently logged in user or any user with the id exists in the given role or not, and checking can be done either in the controller class or in … Continue reading Check User exists in a Role in ASP.NET Identity 2.0

Convert User to ApplicationUser in ASP.Net MVC

In the last post I talked about How to get current user in ASP.Net MVC 5 . Type of the current user is IPrincipal which is shown as follows: You may come across requirement to work with ApplicationUser which is created as follows: You can covert returned User to ApplicationUser as follows: To convert create … Continue reading Convert User to ApplicationUser in ASP.Net MVC

How to get current user in ASP.Net MVC 5

There are two simple ways to get current user in MVC 5. If you are inside the controller class current user can be fetched as follows, Do not forget to add namespace,   Other scenario could be that you are not inside the controller class and want to fetch the user information. You can fetch … Continue reading How to get current user in ASP.Net MVC 5