1

My MVC application is consuming a WCF service to interact with the database.

That means, a controller action is calling a WCF operation to perform SELECT or CRUD operations in database.

However, I have now enabled Default Membership Provider for MVC site. But I dont know how to enable membership provider to interact with database using WCF service. Also, I do not want to specify connection string in MVC app (as its already been there in WCF).

How can we achieve this?

4

1 回答 1

1

But I dont know how to enable membership provider to interact with database using WCF service.

There's no support for this in the default provider. You will have to write a custom membership provider by deriving from the MembershipProvider class and implementing the methods you need in your application. Note that there are many abstract methods but if you are not using them they don't need to be implemented. For example in the ValidateUser method you will call your WCF service to validate the user credentials. And finally register your custom membership provider in web.config:

<membership defaultProvider="MyProvider">
    <providers>
        <add name="MyProvider" type="Mynamespace.MyProvider, MyAssembly" />
    </providers>
</membership>
于 2013-05-08T09:08:43.133 回答