Membership provider with WCF

Posted by in WCF category on for Beginner level | Views : 36305 red flag
Rating: 5 out of 5  
 2 vote(s)

In this article, we are going to see how to use membership provider with WCF.

        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

Step 4:

   Now at this point of time lets create a certificate. Go through this article


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

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.

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: anup hosur
Member Level:
Member Status: Member
Member Since: 8/1/2009 2:37:23 AM
Country: India
He is the .net developer with around 8 years of experience in technologies like c#, WCF, WPF and

Login to vote for this post.

Comments or Responses

Posted by: Lopez.obrador on: 1/4/2011 | Points: 25
Hi anup.
GREAT article. I'm kind of a noob in .NET so some of the concepts are totally unknown to me plus some of the config code is not fully visible.
Also, I'm not fully sure as to where the certs should be placed (In the client and server) And where should Step 11 be written, In the Service web.config??
Would it be possible to get the project so I can take a look at it PLEASE !!

Many thanks.

Posted by: Anup1252000 on: 1/5/2011 | Points: 25
Hi Lopez,

Thanks for reading the article.Step11 is nothing but a client Config.
I will add sample solution to this article in a day or 2. After adding i will let you know.

Posted by: Sonisp on: 12/13/2011 | Points: 25
Dear Anup,

Am trying this example, and was able to create the certificate as instructed above. But I have the following queries,

1. The link for getting Thumbprint of the certificate I just created talks about finding based on "Intended Purpose=Client Authentication", but based on your command the certificate which i created has this value "Intended Purpose=Server Authentication". Any What am i doing wrong? Or can I use the same regardless of the value of Intended Purpose.

2. How would this approach help when i have the client application trying to consume the same Service from another machine? Do I need to install the certificated per client on each local machine?

Posted by: Anup1252000 on: 12/13/2011 | Points: 25
1) Use the same certificate if you doing it for testing purpose. If you want to use in production then create different certificate for client.
2) Yes you have to install certificate on each client m/c.

Let me know if you have any issue on the same.

Login to post response

Comment using Facebook(Author doesn't get notification)