ASP.NET Custom MemberShip Provider Database

Here i'm explaining how to Create And Use Custom MemberShip Provider Database in ASP.NET 2.0, If you want to use Custom or your own DataBase as membership Provider instead of ASPNETDB.MDF database provided by membership provider class, than follow the steps mentioned in this article.

In this example i m going to describe how to change and use custom Database with Login Control in ASP.NET.

First of all you need to create DataBase schema for membership.
For this create a DataBase in sql server with any name you want.
Now open Visual studio command prompt and type aspnet_regsql , press enter
this will open wizard window to setup database for membership provider

Create Custom MemberShip Provider Database in ASP.NET
Alternatively you can Go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and run aspnet_regsql.exe from there
Follow the steps according to images
Use Custom MemberShip Provider Database in ASP.NET 
 Choose your Database Server and DataBase Name 

Now open web.config file and write below mentioned code 
Add connection string
    <add name="ConnectionString" 
Now add this code in System.web section of web.config
<roleManager defaultProvider="CustomProvider">
 <add connectionStringName="ConnectionString" 
 type="System.Web.Security.SqlRoleProvider" />

<membership defaultProvider="CustomMembershipProvider">
<add name="CustomMembershipProvider"
     connectionStringName="ConnectionString" />

After this click on website menu in Visual Studio and select ASP.NET Configuration 
GO to Provider Tab and click on Select a different provider for each feature (advanced) option 

Now create users by going to security tab 
Your custom membership provider with your own custom databse configuration is done 
Build and test the application 

If you like this post than join us or share


Anonymous said...

You can't believe how much you just helped me. Thanks you so much.

Anonymous said...

hey amit,
u saved many hours of mine.

Unknown said...

this is very good.I used it in my application.when i run my website using visual Studio connected with remote db it works nice but when i deploy it on net than it shows password is incorrect.i tryed it more than two user but the problem is same.please help i need help very

Unknown said...

@abhishek Singh:

Please check the connection string in Your web.config file under membership defaultProvider="CustomMembershipProvider" section

Sean Olson said...

Hi Amit,

Thanks for breaking this down so nicely. I book-marked you on Stumble and Digg. Good work!


Unknown said...

@Sean Olson:

Thanks a lot for the appreciation and favor :)

Keep visiting

Anonymous said...

thanks amit!
i will sleep today properly after
one week .
thnks again


Anonymous said...

good looking

Anonymous said...

awesome BRO helped alot, i took 2 hrs in configuring this ~am new to thanks not

Anonymous said...

AmiT i am trying to set up authentication from a databse called student.mdf with a table names Auth with name and psw feilds i dont think whats above can help me, any thing u can help me with?


Custom Paper Writing said...

Many institutions limit access to their online information. Making this information available will be an asset to all.

Anonymous said...

I already did this. How can I authenticate the 2nd page? Example, if I will type the url of the second page, I will not access it unless I enter my username and password whether I'm an admin or not.

Anonymous said...

Hello Amit,
I have a question. When I start aspnet_regsql.exe, the procedure creates tables structure into a db. But can I use different tables structure ? I need to use other tables structure that defines roles and permissions at different level, instead of its own structure.

Thank you

Anonymous said...

It was certainly interesting for me to read that post. Thank you for it. I like such topics and anything that is connected to this matter. I definitely want to read a bit more soon.

Anonymous said...

Thanks, it works great!!!

Anonymous said...

please update at time

Anonymous said...

It was very interesting for me to read that post. Thanks for it. I like such themes and anything that is connected to them. BTW, try to add some photos :).

Mitendra said...

To create DataBase schema for membership:-

Command Line did the trick:-

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql -S -A
m -U -P l

Start adding the following features:




Don't know why Wizard was behaving idiotic and throwing error.


Anonymous said...

Thank you so much

Anonymous said...

hey man.. u describe to chose custom membership in database but i got the option of choosing
master,msdb,tempdb,model.... indeed there's no custom membership option.. in database
what to do.. now?
plz help.. waiting for rply....

Marysita said...

I´ve read this and it´s very useful for begin with this. Thanks a lot

Kristian said...

Thank you thank you thank you!

Anonymous said...

Thank you...after two days of fiddling around and numerous attempts on google i found your site with clear instructions...please keep up the good work.

Anonymous said...

thnks alot

arashi kensho said...

nice info.. Visit to my blog Okey..!!! Thanks!!

Unknown said...

Hi Amit,
i am facing a problem,My database sever only open in window authentic mode because i don't know by default login password. Please tell me window authentication setting code in web config file.

Unknown said...

amiT, thank you so very much! This article was just the thing I needed. I was having probs connection to my SQL database via LINQ and then iterating thru the entries to check if the user exists!!!!

Thank you so much!

Do you have a blog of you own? I wanna subscribe! thanks so much!!!!

Anonymous said...

i did read, it is very useful material
Thanks alot

Anonymous said...

Keep it up amit...good job.
All of your articles are very helpful.
Thanks for sharing your expertly


Anonymous said...

soooooooo sweet of you buddy....thanx a lot

Anonymous said...

thanx a lot.. u saved me from the hell

Navtej Singh said...

hi amit
its a brilliant kinda code
i tried it with my web application on XP, it works fine but in case of windows server it doesn't work at all....
can you help me ... ?

Anonymous said...

Thank you so much for the post. One question if i may, when i publish my website everything works correctly, except folder permissions. Locally, all the folders are locked as specified in config, but after publish they are all available to any user role. any suggestions are much appreciated!!

rabindramajhi said...

how to get database "CustomMembership"

Unknown said...

@rabindramajhi: Hi, you just need to create a empty database with any name in your sql server, i created a blank database with name customMembership for this example and used it

Anonymous said...

pharmacy technician jobs dallas texas pharmacy benefit manager positions in san francisco

Anonymous said...


Anonymous said...

Thanks this was really helpful

Anonymous said...


I just want make sure whether i did follow up the article. If i understand clearly you saying.

I must open my Sql Server Management Studio, create an empty database.

Command Prompt...
Configuration Page..Create User and Roles

So what i want to understand is, will this create the "User, Roles, Profile, UserGroup tables" as you find in aspnet built in database or i should create the table by myself first.

Anonymous said...

I just want make sure whether i follow up. What you said is that:

1. I Open my Sql Server Management Studio
2. Create an Empty database without tables
3. VS Command Prompt
4. Configuration Page

One other question is that will the tables like "Users, Roles, Profiles, UserGroup" be created automatically?

Unknown said...

@Above : yes it will create all tables etc

Find More Articles