In the login page I am determining if the user is admin or not by the following code:
if (r.IsUserInRole(txtUserUsername.Text, "User") == true)
{
connection = ConfigurationManager.ConnectionStrings["GameHutDBEntities1"].ToString();
switch (new BusinessLayer.Users().ValidateLogin(txtUserUsername.Text, txtUserPassword.Text, connection))
{
case Helpers.LoginStatus.LoginSuccessful:
{
Response.Write("<Script> alert('Welcome to GameHut Admin Panel!')</Script>");
FormsAuthentication.RedirectFromLoginPage(txtUserUsername.Text, chkRemember.Checked);
break;
}
case Helpers.LoginStatus.Blocked:
{
Response.Write("<Script> alert('Account Blocked')</Script>");
break;
}
case Helpers.LoginStatus.Invalid:
{
Response.Write("<Script> alert('Invalid username or password')</Script>");
break;
}
}
}
In the connection class I am passing the connection string as follows:
public class ConnectionClass
{
public GameHutDBEntities Entities { get; set; }
public System.Data.IDbTransaction Transaction { get; set; }
public ConnectionClass()
{
this.Entities = new GameHutDBEntities();
}
public ConnectionClass(GameHutDBEntities _Entities)
{
this.Entities = _Entities;
}
public ConnectionClass(GameHutDBEntities _Entities, string conn)
{
this.Entities = _Entities;
this.Entities.Connection.ConnectionString = conn;
}
}
After the admin is logged and is redirect into another page the connection string is lost and the default connection string is set? Can someone tell me how to keep the connection string as long as the user logs out.