Results 1 to 3 of 3

Thread: how to do form authentocation

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2003
    Location
    india
    Posts
    273

    how to do form authentocation

    I am new inasp.net, I am giving form authentication to my web site for that i have
    written following code in web.config file.On compilation it is giving me error.
    like unable to start your project .....
    can any body help me out.

    thanks & regards
    PPCC

    the code goes here..

    <authentication mode="Forms"/>

    <forms name="formsauth1" loginUrl="Login.aspx" protection="all" timeout="30" path="/">

    <location path="Login.aspx"> [This can also be a folder]

    <authorization>
    <deny users="?" />
    </authorization>

    </location>

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    you closed the authentication tag too early...


    <authentication mode="Forms" />

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    This is what I use:
    Code:
    <authentication mode="Forms">
        <forms loginUrl = "Login.aspx"/>
    </authentication>
    
    <authorization>
        <allow users="?" />
    </authorization>
    And then in my login page I have:
    VB Code:
    1. Imports System.Web.Security
    2.  
    3. Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    4.     Dim objTicket As FormsAuthenticationTicket
    5.     Dim objCookie As HttpCookie
    6.     Dim strReturnURL As String
    7.     If ValidateLogin() Then
    8.         objTicket = New FormsAuthenticationTicket(txtUsername.Text, False, 30)
    9.         objCookie = New HttpCookie(".ASPXAUTH")
    10.         objCookie.Value = FormsAuthentication.Encrypt(objTicket)
    11.         Response.Cookies.Add (objCookie)
    12.         strReturnURL = Request.Params("ReturnURL")
    13.         If strReturnURL Is Nothing Then
    14.             Response.Redirect ("Main.aspx")
    15.         Else
    16.             Response.Redirect (strReturnURL)
    17.         End If
    18.     Else
    19.         lblMessage.Visible = True
    20.         lblMessage.Text = "Invalid username/password."
    21.     End If
    22. End Sub
    Does that help?

    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