Saturday, 3 August 2013

Membership Provider in .net

This is going to be very basic lets say introductory post about Membership Provider in .net applications , its purpose,usage and what is more better than that.Basically whenever you want to restrict users to access resources and check credentials to log-in to some system then we need a perfect "Login Regestration" system and that is what Membership Provider simply  does.
On abstraction we have users and they have to register first and then log-in to get access to resources on our website and if we are using Membership Provider we can implement this flow within a second with some extra features too.It provides us with number of methods to use its funcitonality. e.g

 MembershipUser user = Membership.CreateUser("UserName", "Password");

It provides number of features like generate passwords, online users , get users etc you can find it in the link above. Now lets talk about how it manages the database, it handles all database operations by itself, we just need to know where to use its functionality all background work will be done automatically.

So what we have to do to update our database so that membership can use our database to perform its functionality, there are two simple steps to create our database, i.e.

1) Open visual studio command prompt and run the command "aspnet_regsql"

2) This will open a window and where you can select your database and follow the window till finish

Now open your database and see in the tables, membership tables will be created, so you are ready to use Membership provider features.