1

I tried to develop custom membership provider in order to use with my own database tables but I couldn't. After run project I saw red error line on web.config custom membership provider line. :( type="Mvc4ApplicationTest2.Models.CustomMembershipProvider" I found article that said me to add below lines to web.config and I did.

add key="enableSimpleMembership" value="false"
add key="autoFormsAuthentication" value="false" 

Now application run :) but after get to login page and clicked on submit i get to new error that hint me like this:

To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".

Again I searched and I found some articles says me have to add prior line to web.config but with true value !!? add key="enableSimpleMembership" value="true" I confused. ?( So What can I do? Can everyone please help me? and other question, I want to use the standard, strong and useful method to secure my web application. do you think if I must use websecurity classes or other approach?

Sincerely Ali

4

2 回答 2

3

以下是我在 MVC 4 项目的 Web.config 文件中注册自定义成员资格提供程序的方式:

<membership defaultProvider="MyCustomMembershipProvider">
    <providers>
        <clear />
        <add name="MyCustomMembershipProvider" type="MyProject.MyCustomMembershipProvider, MyProject" connectionStringName="MyConnectionString" />
    </providers>
</membership>

请注意,“MyProject.MyCustomMembershipProvider”应该是您的成员资格类的完全限定路径,“MyProject”是它所包含的程序集的名称(通常是您的项目名称)。

还要确保您的成员资格提供程序类扩展了 MembershipProvider,如下所示:

public class MyCustomMembershipProvider : MembershipProvider
{
    // Code here
}

我的 Web.config 中没有“enableSimpleMembership”或“autoFormsAuthentication”行。

希望这会有所帮助!

于 2012-11-17T00:51:32.173 回答
2

After searching a lot and reading many articles I found it Finally. That is stupid mistake. I used to inherit from System.Web.Security.MembershipProvider. so I took error about needing ExtendedMembershipProvider implementation. So I did it with WebMatrix.WebData.ExtendedMembershipProvider and then every things were fine. Thanks for all advises and helps.

于 2012-11-23T22:05:28.463 回答