Description:
I'm trying to do a simple thing: using.Net MVC with MySQL 5.1.39.
The problem happens on the GetUserId function on the connector that throws an invalidcast exception when i try to login with a created user! I just used the default code given by the MVC Application template in VS2008, so it should be quite straight forward, right?
This happened with the 6.2.3 and 6.1.4 versions of the connector
[InvalidCastException: Specified cast is not valid.]
MySql.Web.Security.MySQLMembershipProvider.GetUserId(MySqlConnection connection, String username) +177
MySql.Web.Security.MySQLMembershipProvider.ValidateUser(String username, String password) +89
JogoABola.Controllers.AccountMembershipService.ValidateUser(String userName, String password) in C:\Users\Diogo\Desenvolvimento\jogoabola\JAB\JogoABola\Controllers\AccountController.cs:335
JogoABola.Controllers.AccountController.ValidateLogOn(String userName, String password) in C:\Users\Diogo\Desenvolvimento\jogoabola\JAB\JogoABola\Controllers\AccountController.cs:207
JogoABola.Controllers.AccountController.LogOn(String userName, String password, Boolean rememberMe, String returnUrl) in C:\Users\Diogo\Desenvolvimento\jogoabola\JAB\JogoABola\Controllers\AccountController.cs:59
lambda_method(ExecutionScope , ControllerBase , Object[] ) +245
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
[...]
The Web.Config part looks like this:
[...]
<membership defaultProvider="MySQLMembershipProvider2">
<providers>
<add autogenerateschema="true" connectionStringName="JABMySqlServer"
enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false"
applicationName="/" requiresUniqueEmail="true" passwordFormat="Clear"
minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
maxInvalidPasswordAttempts="5" passwordAttemptWindow="5" passwordAnswerAttemptLockoutDuration="30"
passwordStrengthRegularExpression="" name="MySQLMembershipProvider2"
type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</providers>
</membership>
<profile defaultProvider="MySQLProfileProvider2">
<providers>
<add name="MySqlProfileProvider2" autogenerateschema="true" connectionStringName="JABMySqlServer" applicationName="/" type="MySql.Web.Security.MySQLProfileProvider, MySql.Web, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</providers>
</profile>
<roleManager enabled="true" defaultProvider="MySqlRoleProvider2">
<providers>
<add autogenerateschema="true" connectionStringName="JABMySqlServer"
applicationName="/" name="MySqlRoleProvider2" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</providers>
</roleManager>
[...]
How to repeat:
Install the Connector/Net 6.2.3 and use a MVC template in VS2008.
Then create a user and try to login.