I am working on my first login in this language, which when entering the correct credentials (user and password) will direct you to a specific page depending on whether you are a common user or administrator according to the assigned idRole, as shown.
DataTable dt = new DataTable();
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["username"] = txtUserName.Text.Trim();
if (dt.Rows[0]["IdRole"].ToString() == "2")
Response.Redirect("user/Default.aspx");
else if
(dt.Rows[0]["IdRole"].ToString() == "1")
Response.Redirect("admin/Default.aspx");
}
else
{
lblErrorMessage.Visible = true;
}
In the pages you are directed to, you have a condition that prevents you from entering them unless there is a current session.
The problem is that if a logged-in user simply changes the address of this; user / Default.aspx to this; This already has access to its controls. What methods can I use to solve these problems?