Issue with Login Control/ MySqlMembershipProvider.ValidateUser
-
- Posts: 2
- Joined: Wed 21 Mar 2007 14:48
- Location: Maryland, USA
Issue with Login Control/ MySqlMembershipProvider.ValidateUser
When running ASP.NET app against latest MySQLDirect.NET MySQL 5, I get an exception:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 26:
Line 27: CoreLab.MySql.Web.Providers.MySqlMembershipProvider mp = new CoreLab.MySql.Web.Providers.MySqlMembershipProvider();
Line 28: Authenticated = mp.ValidateUser(userLoginControl.UserName, userLoginControl.Password);
Line 29: //}
Line 30: //catch (Exception ex)
Source File: d:\Projects\RAC\SupportSystem\login.aspx.cs Line: 28
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
CoreLab.Common.Web.Providers.DbMembershipProvider.a(String A_0) +297
CoreLab.Common.Web.Providers.DbMembershipProvider.a(String A_0, String A_1) +100
CoreLab.Common.Web.Providers.DbMembershipProvider.ValidateUser(String username, String password) +55
login.userLoginControl_Authenticate(Object sender, AuthenticateEventArgs e) in d:\Projects\RAC\SupportSystem\login.aspx.cs:28
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +106
System.Web.UI.WebControls.Login.AttemptLogin() +105
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
-
- Posts: 2
- Joined: Wed 21 Mar 2007 14:48
- Location: Maryland, USA
I think NullReferenceException is a designed behaviour. SQL Server membership provider works the same way. You should initialize your user before calling Validate() method. Take a look at the following code:
Code: Select all
System.Collections.Specialized.NameValueCollection coll = new System.Collections.Specialized.NameValueCollection(1);
coll.Add("connectionStringName", "MySqlServices");
mp.Initialize("AspNetMySqlMembershipProvider", coll);