While I was working on my localhost it worked flawlessly.
However, when I deployed the application to another server it started to raise an exception.
Basically, this is the instruction that causes the Exception:
HttpContext.Current.User.IsInRole(*roleName*)
where roleName is a string representing the different roles in the application.
Exception fired:
System.Web.HttpUnhandledException
Update: This is how the user is being authenticated.
protected void LoginControl_Authenticate(object sender, AuthenticateEventArgs e)
{
Page.Validate();
if (!Page.IsValid) return;
if (MyAuthenticate(LoginControl.UserName, LoginControl.Password))
{
if (LoginControl.RememberMeSet == true)
{
createCookie(LoginControl.UserName, Convert.ToInt32(ViewState["idcustomer"]), true);
}
else
{
createCookie(LoginControl.UserName, Convert.ToInt32(ViewState["idcustomer"]), false);
}
e.Authenticated = true;
Response.Redirect(FormsAuthentication.GetRedirectUrl(LoginControl.UserName, true));
}
else
{
e.Authenticated = false;
}
If it is related to the user authentication, what am I missing? Thanks in advance.
UPDATE: Thanks to all. I have just done a Remote Debugging and realize this is the actual error:
Now, this is the situation: the User was authenticated in the login page. So, I think it is not a problem with the connection to the DB. Otherwise, the User wouldn't have been able to pass the login page to the MasterPage (where this error is being raised).
What can I be missing? Thanks again,
The solution for this problem was to create the mysql_aspnet_membership provider by granting full trust through the machine.config and autogenerating the schema, instead of manually creating the membership tables in the database, which I though there could have been a valid way to create the db.
Afterwards, this didn't break anymore.