Results 1 to 2 of 2

Thread: Authorisation to view web site. RESOLVED

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Authorisation to view web site. RESOLVED

    What code do I need to force users to sign into my web page?
    I have a login screen, and ado code that verifies the username/password against my DB, but what code should I use so that users can now view other pages in my site.
    Is it Forms security I want?
    Do I need to store a cookie to do this?

    Wood

  2. #2

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Have got the code:
    VB Code:
    1. Dim objTicket As FormsAuthenticationTicket
    2.         Dim objCookie As HttpCookie
    3.         Dim strReturnURL As String
    4.             If ValidateLogin(txtUsername.Text, txtPassword.Text) Then
    5.                 objTicket = New FormsAuthenticationTicket(txtUsername.Text, False, 5)
    6.                 objCookie = New HttpCookie(".ASPXAUTH")
    7.                 objCookie.Value = FormsAuthentication.Encrypt(objTicket)
    8.                 Response.Cookies.Add(objCookie)
    9.                 strReturnURL = Request.Params("ReturnURL")
    10.                 If strReturnURL Is Nothing Then
    11.                     Response.Redirect("Main.aspx")
    12.                 Else
    13.                     Response.Redirect(strReturnURL)
    14.                 End If
    15.             Else
    16.                 lblMessage.Text = "Incorect username/password"
    17.             End If
    And the values in the config file:
    Code:
        <authentication mode="Forms">
                <forms
                      loginUrl="login.aspx" 
                      protection="All"
                      slidingExpiration="true" 
                />
        </authentication> 
    
        <authorization>
                <deny users="?" />
        </authorization>
    Woof

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width