I tried to insert this into my webconfig:
<authentication mode="Forms">
<forms loginUrl="InnUtlogging.aspx" timeout="2880"/>
</authentication>
here is my code for the "login"-button (on the login-page);
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("select * FROM Ansatt WHERE epost='" + brukernavn.Text + "' and passord='" + passord.Text + "'");
cmd.Connection = con;
int OBJ = Convert.ToInt32(cmd.ExecuteScalar());
if (OBJ > 0)
{
Session["name"] = brukernavn.Text;
Response.Redirect("KunstnerAdmin.aspx");
}
else
{
melding.Text = "Feil brukernavn/passord";
}
if (brukernavn.Text == "")
{
melding.Text = "Du må fylle inn brukernavn";
}
if (passord.Text == "")
{
melding.Text = "Du må fylle inn passord";
}
}
But actually I want to check if user is logged in in the master-page.
Is there something I can do in the masterpage to activate the forms authentication?