I have setup a ASP.NET web application.
I have 2 forms:
  • Login.aspx
  • Main.aspx

My login page is bog standard. Username and password textboxes, a msg label and a login button.
My main page has a picture...simple

The code for the login page is:
VB Code:
  1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         'Put user code to initialize the page here
  3.         lblMessage.Text = vbNullString
  4.         Session.Abandon()
  5.         FormsAuthentication.SignOut()
  6.     End Sub
  7.  
  8.     Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
  9.         Dim objTicket As FormsAuthenticationTicket
  10.         Dim objCookie As HttpCookie
  11.         Dim strReturnURL As String
  12.         If IsValid Then
  13.             If txtUsername.Text = "wokawidget" And txtPassword.Text = "woof" Then
  14.                 objTicket = New FormsAuthenticationTicket(txtUsername.Text, False, 5)
  15.                 objCookie = New HttpCookie(".ASPXAUTH")
  16.                 objCookie.Value = FormsAuthentication.Encrypt(objTicket)
  17.                 Response.Cookies.Add(objCookie)
  18.                 strReturnURL = Request.Params("ReturnURL")
  19.                 If strReturnURL Is Nothing Then
  20.                     Response.Redirect("Main.aspx")
  21.                 Else
  22.                     Response.Redirect(strReturnURL)
  23.                 End If
  24.             Else
  25.                 lblMessage.Text = "Incorect username/password"
  26.             End If
  27.         Else
  28.             lblMessage.Text = "Incorect username/password"
  29.         End If
  30.     End Sub
...and I have the following in my web.config file:
Code:
<authentication mode="Forms">
	<forms
		name=".opsreport" 
		loginUrl="login.aspx" 
		protection="All"
		slidingExpiration="true" 
		timeout = "10"
	/>
</authentication> 
<authorization>
        <allow users="*" /> <!-- Allow all users -->
	<deny users="?" /> <!-- Deny anon users -->    
</authorization>
Now, according to all the stuff I have read then this should force users to get redirected to my login page if they have not signed in. However, it allows me to view the main.aspx page WITHOUT having to login

Why?

Woka