title: <authentication mode="Forms"> doesnt work?
body: <p>I have a login-page where users can log in. When they logging in with correctly details they are sent to an main admin-page. If they cant log in they are staying on the login-page. What I want to do is, if a random user, type in the URL for an admin-page when they are not logged in they are redirecting to the login-page.</p>
  
  <p>I have understood that I have to do it in the masterpage or webconfig!?! I have a main admin-page and some other admin-pages.</p>
  
  <p>Any tips?</p>
  
  <p>I tried to insert this into my webconfig:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
      &lt;forms loginUrl="InnUtlogging.aspx" timeout="2880"/&gt;
    &lt;/authentication&gt;
  </code></pre>
  
  <p>here is my code for the "login"-button (on the login-page);</p>
  
  <pre><code>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 &gt; 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";
          }
          }
  </code></pre>
  
  <p>The code on the "login"-page works for that page, but I actually 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?</p>