asp.net - Cant configure MVC 4 SqlMembershipProvider -
i setting mvc 4 website use sqlmembershipprovider data store sql server express 11.0.21xx
i have installed universal providers via nuget
pm > install-package microsoft.aspnet.providers
when run app , go localhost/accounts/register , submit form, error
to call method, "membership.provider" property must instance of "extendedmembershipprovider".
at line
websecurity.createuserandaccount(model.username, model.password);
accounts controller has attribute [initializesimplemembership]
set. tables not created due aforementioned error.
web.config section updated nuget
<profile defaultprovider="defaultprofileprovider">
<providers>
<add name="defaultprofileprovider" type="system.web.providers.defaultprofileprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" />
</providers>
</profile>
<membership defaultprovider="defaultmembershipprovider">
<providers>
<add name="defaultmembershipprovider" type="system.web.providers.defaultmembershipprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"
connectionstringname="defaultconnection"
enablepasswordretrieval="false"
enablepasswordreset="true"
requiresquestionandanswer="false"
requiresuniqueemail="false"
maxinvalidpasswordattempts="5"
minrequiredpasswordlength="6"
minrequirednonalphanumericcharacters="0"
passwordattemptwindow="10"
applicationname="/" />
</providers>
</membership>
<rolemanager enabled="true" defaultprovider="defaultroleprovider">
<providers>
<add name="defaultroleprovider"
type="system.web.providers.defaultroleprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" />
</providers>
</rolemanager>
<sessionstate mode="inproc" customprovider="defaultsessionprovider">
<providers>
<add name="defaultsessionprovider" type="system.web.providers.defaultsessionstateprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" />
</providers>
</sessionstate>
connectionstring
<add name="defaultconnection" connectionstring="server=servername\instance;database=imdb;user id=sa; password=passbird;" providername="system.data.sqlclient" />
where's problem? should use universal providers @ all? dont believe should run aspnet_regsql cos of new account controller.
all had change defaultmembershipprovider simplemembershipprovider in web.config. type attribute important right.
<membership defaultprovider="defaultmembershipprovider"> <providers> <add name="defaultmembershipprovider" type="webmatrix.webdata.simplemembershipprovider, webmatrix.webdata" connectionstringname="defaultconnection" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="false" requiresuniqueemail="false" maxinvalidpasswordattempts="5" minrequiredpasswordlength="6" minrequirednonalphanumericcharacters="0" passwordattemptwindow="10" applicationname="/" /> </providers> </membership> <rolemanager enabled="true" defaultprovider="defaultroleprovider"> <providers> <add name="defaultroleprovider" type="webmatrix.webdata.simpleroleprovider, webmatrix.webdata" connectionstringname="defaultconnection" applicationname="/" /> </providers> </rolemanager>
Comments
Post a Comment