[RESOLVED]ASP.NET Membership Role in Windows Application
Hi all,
i already create new connectionstring in app.config that point to myDB
i already create aspnet membership table in myDB using aspnet_regsql
i already create new custom provider and set the connection string there..
what i like to ask:
1. why when the app start, it create new folder app_data which contain aspnetDB.mdf eventhough i already create new connection string ?
2. why when i'm using Membership.CreateUser method, it succesfully inserted in myDB.aspnet_Users table but when i'm using Roles.CreateRole method it doesn't inserted in myDB.aspnet_Roles table?
need insight, been troubleshoot this for 2 days :(
PS: i'm using .net 4.0, sql2008, vs2010
thanks,
erick
Re: ASP.NET Membership Role in Windows Application
Are u using winforms or asp.net?
Your problem is proly the config file.
You said you have created a custom provider.Have done for both membership and roleManager ?
Can you show us what you have done?
Re: ASP.NET Membership Role in Windows Application
Quote:
Originally Posted by
sapator
Are u using winforms or asp.net?
Your problem is proly the config file.
You said you have created a custom provider.Have done for both membership and roleManager ?
Can you show us what you have done?
thx sapator
i'm using winforms
here is my custom provider
Code:
public class mySQLMembership : SqlMembershipProvider
{
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);
// Update the private connection string field in the base class.
string connectionString = myConnectionString here;
// Set private property of Membership provider.
FieldInfo connectionStringField = GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
connectionStringField.SetValue(this, connectionString);
}
}
here is section in app.config
Code:
<membership defaultProvider="mySQLMembership">
<providers>
<clear />
<add name="mySQLMembership"
type="DGex.Business.mySQLMembership, DGex.Business"
connectionStringName="DGexEntities"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/DGex"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<roleManager enabled="true"></roleManager>
Have done for both membership and roleManager ? -> hm, we need to create our own custom membership and rolemanager?? i'm not done that..i'm using Roles and Membership class to create role, user, etc..am i doing wrong?
basically i want to use this provider but i need it to point to real SQL DB, not using SQL Express aspnetDB.mdf
PS: oopss just realize i post at wrong forum..sorry, can moderator move it..sorry for the trouble
thx
Re: ASP.NET Membership Role in Windows Application
You need a role provider,yes.
An example:
Code:
<roleManager defaultProvider="RoleProvider" enabled="true">
<providers>
<clear/>
<add name="RoleProvider" connectionStringName="myConnectionString" applicationName="MyApplication" type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<membership defaultProvider="MyProvider" userIsOnlineTimeWindow="20">
.....etc
Re: ASP.NET Membership Role in Windows Application
Quote:
Originally Posted by
sapator
You need a role provider,yes.
An example:
Code:
<roleManager defaultProvider="RoleProvider" enabled="true">
<providers>
<clear/>
<add name="RoleProvider" connectionStringName="myConnectionString" applicationName="MyApplication" type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<membership defaultProvider="MyProvider" userIsOnlineTimeWindow="20">
.....etc
yes, finally it working...silly me, i thought it's only using rolemanger enabled="true" :D
thx for pointing me at correct direction sapator
but it still create app_bin folder which contain aspnetdb.mdf..why?
Re: ASP.NET Membership Role in Windows Application
Since u use a custom Mysql i cannot be sure since i only have used strait SQL.I'll investigate a little and if i find anything i will post it.But i think the people on the local asp thread can give you a correct answer.
For a quick test try to change your "type" to the standard mysql type.Here is an example in sql server, just use the mysql credentials
Code:
<add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString"
Re: ASP.NET Membership Role in Windows Application
Quote:
Originally Posted by
sapator
Since u use a custom Mysql i cannot be sure since i only have used strait SQL.I'll investigate a little and if i find anything i will post it.But i think the people on the local asp thread can give you a correct answer.
For a quick test try to change your "type" to the standard mysql type.Here is an example in sql server, just use the mysql credentials
Code:
<add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString"
already use the default provider value, only change in connectionstring
Code:
<system.web>
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="DGexEntities"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="DGex"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" connectionStringName="DGexEntities" applicationName="DGex" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
</system.web>
Re: ASP.NET Membership Role in Windows Application
Aha.
I think that is your problem.
You will not supply the default asp provider but a custom one.
P.E.
Code:
<membership defaultProvider="MyProvider" userIsOnlineTimeWindow="20">
<providers>
<add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString" applicationName="MyApplication" enablePasswordRetrieval="true" enablePasswordReset="true" ......etc/>
</providers>
</membership>
Re: ASP.NET Membership Role in Windows Application
yes, u are correct sapator
after i changed the name, it not create app_bin folder anymore
now i can sleep tight :D
very thx for the help...
Re: [RESOLVED]ASP.NET Membership Role in Windows Application
No problem.
Please mark the thread as resolved.