asp.net - SimpleMembershipProvider in WebSite with Profile -
i created new website in vs2012 - not project - added connection string, created tables, , using aspnet configuration created couple of roles , user, in turn automatically created appropriated tables in database: users, usersinroles, roles, memberships , roles. pretty working expected. 4.5 (simplemembershipprovider) doesn't create stored procedures , code used old membershipprovider.
i wanted add fields in profile provider, use membershipprovider:
<properties> <add name="mywhatever" type="system.int32" allowanonymous="false"/> </properties>
but when try call in code behind, said "profile" doesn't exists. search on web , read vs2012, if create website, instead of project, doesn't come profile default have create custom one.
following added following code in appcode cs:
namespace mynamespace {
public class userprofile : profilebase { public static userprofile getuserprofile(string username) { return create(username) userprofile; } public static userprofile getuserprofile() { return create(membership.getuser().username) userprofile; } [settingsallowanonymous(false)] public string mywhatever1 { { return base["mywhatever1"] string; } set { base["mywhatever1"] = value; } } }
in webconfig:
<profile defaultprovider="myprofileprovider" inherits="mynamespace.userprofile"> <providers> <clear /> <add name="myprofileprovider" type="system.web.profile.sqlprofileprovider" connectionstringname="mydbconn"/> </providers> </profile> <membership defaultprovider="mymembershipprovider"> <providers> <clear /> <add name="mymembershipprovider" type="system.web.providers.defaultmembershipprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="mydbconn" applicationname="/"/> </providers> </membership> <rolemanager defaultprovider="myroleprovider"> <providers> <clear /> <add name="myroleprovider" type="system.web.providers.defaultroleprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="mydbconn" applicationname="/"/> </providers> </rolemanager>
i go page behind , recognizes custom profile! i'm exited until run page , this:
could not find stored procedure 'dbo.aspnet_checkschemaversion'.
now what? pretty sure simplemembershiprovider doesn't use stored procedures membershipprovider use to, , don't want install membershipprovider in database. there must can add code works is.
any suggestions??
thanks.
your web.config configured use default providers instead of simplemembership providers. web.config should use simplemembership.
<rolemanager enabled="true" defaultprovider="simpleroleprovider"> <providers> <clear/> <add name="simpleroleprovider" type="webmatrix.webdata.simpleroleprovider, webmatrix.webdata"/> </providers> </rolemanager> <membership defaultprovider="simplemembershipprovider"> <providers> <clear/> <add name="simplemembershipprovider" type="webmatrix.webdata.simplemembershipprovider, webmatrix.webdata" /> </providers> </membership>
simplemembership providers not try call stored procedures used default providers.
also, cannot use asp.net configuration create users , roles when using simplemembership. have create own application or seed database when created described in article. article, , others on internet, geared towards using simplemembership mvc, not web forms. this qa point out should work web forms.
Comments
Post a Comment