In this article, we are going to see how to use membership provider with WCF.
Introduction
In this article, we are going to see how to use membership provider with WCF. Let us go through this application step by step.
Step 1:
Create a new Website->Select a WCFService->name it as service
Step 2:
Here i am keeping interface as it is. In this application, we are suppose to discuss so many things.


Step 3:
Now we are suppose to create a forms authentication database. I suggest you to read this article, it contains information on how to create a forms authentication database
http://msdn.microsoft.com/en-us/library/x28wfk74.aspx
Step 4:
Now at this point of time lets create a certificate. Go through this article
http://www.inventec.ch/chdh/notes/14.htm
Step 5:
Now lets write our web.config.
First connect to database and give the connectionstring

Step 6:
Now create membershipProvider in web.config

Set the authentication mode to Forms
<authentication mode="Forms"/>
Step 7:
Under System.ServiceModel write these lines in web.config

Here I will suggest you to check those imp things
1)Message credential type as UserName
2)negostiate Service credential to false
3)Service cerificate
4)UserNameAuthentication->set UserNamepasswordvalidatormode=MembershipProvider and MembershipProviderName as membership. In my case membership provider name is membership.
To check the thumb print value of the certificate go through this
http://msdn.microsoft.com/en-us/library/ms734695.aspx.
Step 8:
Now create a new console app project->name it as client
Step 9:
Give a service reference to Console app(client)-> name the reference as ServiceReference1
Step 10:

Here i am creating the proxy and setting the username and password in my case username is anup and password is AnUpHoSuR@.
Step 11:
Now create a service certificate in a client as you did in Service.

Step 12:
Its time to run your app

I hope you people like this article.