Hello Forum,
Please how do I secure my web pages or web forms from users who have not registered?
For example I don’t want them to have access to other pages without registering. I sit that I will have to secure Session and redirect them to default page?
This is my session on page load event
protected void Page_Load(object sender, EventArgs e)
{
showdata1();
}
public void showdata1()
{
SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM UserTable WHERE email = '" + Session["user"] + "'";
cmd.Connection = con;
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();
sda.SelectCommand = cmd;
sda.Fill(ds, "detail");
if (ds.Tables[0].Rows.Count > 0)
{
user.Text = ds.Tables[0].Rows[0]["email"].ToString();
}
}