MysqlMembershipProvider debug

MysqlMembershipProvider debug

Postby KW » Wed 11 Feb 2009 19:44

I'm using the membership provider in code:

Code: Select all
MysqlMembershipProvider prov = new MysqlMembershipProvider();

prov.ValidateUser("name","pw");

//Throws error: An exception occured contact your administrator.
// Inner Exception ConnectionString not property not initialized.


I have stepped through the code to find out whats going on but I can't get at the cause. The asp.net administrator page is working correctly, I can add, delete and create users and roles.

The connection string works when using the asp.net admin web page but it won't work in code. Is there a way to get more information on why it wasn't correctly inititialized?

How do I find out what connection string it is trying to use?
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Postby Shalex » Thu 12 Feb 2009 13:39

1. Please try using the membership provider in this way:
Code: Select all
bool var = Membership.ValidateUser("userName", "userPassword");

Check your web.config file for these entries:
Code: Select all

...
   
    
    
   

...
   
    
      
         
            
      

    

...
   


Make sure that the connection string name from the membership section and the connection string name from the connectionStrings section are equal, and the connection string value is valid.

2. If it doesn't help, try running our WebProviders sample ( \Program Files\Devart\dotConnect\MySQL\Samples\Web\CS\WebProviders ). Does it work normally?

3. Please specify the version and edition of dotConnect for MySQL you are using (Tools | MySQL | About).
Shalex
Devart Team
 
Posts: 7473
Joined: Thu 14 Aug 2008 12:44

Postby KW » Fri 13 Feb 2009 18:37

1. Please try using the membership provider in this way:


I use the provider like this:

Code: Select all
MysqlProvider prov = new MysqlProvider(); prov.ValidateUser("asdf","asdf");

//throws error.


Check your web.config file for these entries:

I double checked my config file, everything looks good.


2. If it doesn't help, try running our WebProviders sample ( \Program Files\Devart\dotConnect\MySQL\Samples\Web\CS\WebProviders ). Does it work normally?


I have tried getting this to work but I get the error: failed to map the path '/'.


My connection string looks something like this:

"User ID=user; password=user; Port=3306; Host=Ahost; DataBase=mydb"


Using VERSION 5.0.20.0



The execution location is in a WCF service. But I dont' think this should make a difference. The asp.net trust is full. I've used this code to use the connection string ( copies and pasted from the web.config mysqlmembership provider section)

Code: Select all
MysqlConnection acon = new MyslqConnection( ConfigurationManager.ConnectionStrings["CopiedFromWebConfig"].ConnectionString

MysqlCommand acommand = new MysqlCommand("Select * From aspnet_membership");

acon.open(); MysqlDataReader read = acommand.ExecuteReader();

bool abletoread = read.read(); //abletoread is true


This works fine. It should be the same connection string the MysqlMembershipProvider uses since I copied and pasted it from the webconfig. Why does this work but MysqlMembership not work and how to I know what connection string it is trying to use?
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Postby Shalex » Wed 18 Feb 2009 11:43

The Devart.Data.MySql.Web.Providers.MySqlMembershipProvider class is used for internal implementation by .NET Framework. It is necessary to invoke the Initialize() method to use the MySqlMembershipProvider functionality. The same implementation is used for System.Web.Security.SqlMembershipProvider.

Please use the System.Web.Security.Membership class for your purposes (see my previous post).
Shalex
Devart Team
 
Posts: 7473
Joined: Thu 14 Aug 2008 12:44

Postby KW » Wed 18 Feb 2009 22:14

Shalex wrote:The Devart.Data.MySql.Web.Providers.MySqlMembershipProvider class is used for internal implementation by .NET Framework. It is necessary to invoke the Initialize() method to use the MySqlMembershipProvider functionality. The same implementation is used for System.Web.Security.SqlMembershipProvider.

Please use the System.Web.Security.Membership class for your purposes (see my previous post).


Oh... thanks. Answers my question perfectly.
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12


Return to dotConnect for MySQL