Results 1 to 5 of 5

Thread: Database webform authentication

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Database webform authentication

    I am desperate to find an example of webforms authentication using Vb.net/asp.net and SQL Server.

    The examples I have found so far are all in C# require xml or are confusing.

    Can anyone help?

    I used to do this type of thing in my sleep in good old asp.

    Thanks in advance

    Parksie

  2. #2
    Lively Member
    Join Date
    Nov 2001
    Location
    Dallas
    Posts
    73

    hope this helps

    Hello,

    I had the same problem as you, I found this article to be very helpful, and was able to get it to work just fine.

    http://support.microsoft.com/default...b;EN-US;308157

    Kenny

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    This is what I sue and it seems to work.
    I am not to hot at ASP.NET yet, but it seems straight forward.

    In your Web.Config file you need:
    Code:
        <authentication mode="Forms">
    		<forms
    			name=".ASPXAUTH" 
    			loginUrl="login.aspx" 
    			protection="All"
    			slidingExpiration="true" 
    			timeout = "10"
    		/>
        </authentication> 
        <authorization>
    		<deny users="?" />
        </authorization>
    I have a login page, which I am assuming you have to.
    The code in my "login" button is:
    VB Code:
    1. Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    2.         Dim objTicket As FormsAuthenticationTicket
    3.         Dim objCookie As HttpCookie
    4.         Dim strReturnURL As String
    5.         If IsValid Then
    6.             If txtUsername.Text = "wokawidget" And txtPassword.Text = "woof" Then
    7.                 objTicket = New FormsAuthenticationTicket(txtUsername.Text, False, 5)
    8.                 objCookie = New HttpCookie(".ASPXAUTH")
    9.                 objCookie.Value = FormsAuthentication.Encrypt(objTicket)
    10.                 Response.Cookies.Add(objCookie)
    11.                 strReturnURL = Request.Params("ReturnURL")
    12.                 If strReturnURL Is Nothing Then
    13.                     Response.Redirect("Main.aspx")
    14.                 Else
    15.                     Response.Redirect(strReturnURL)
    16.                 End If
    17.             Else
    18.                 lblMessage.Text = "Incorect username/password"
    19.             End If
    20.         Else
    21.             lblMessage.Text = "Incorect username/password"
    22.  
    23.         End If
    24.     End Sub
    You need to import System.Web.Security for this.
    I am currently learning more about this subject, and am just in the process of having users in a DB table.

    Both the Login page, and the web config file, have references to ".ASPXAUTH". These MUST be the same name! It could be ".WOOF" for all you care, but so long as they are the same it will work.

    Woka

  4. #4

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    I asked this question 2 years ago.

    Such speed!!

  5. #5
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    I try my best

    Hahaha...ooops. I did a search as I was looking for some extra info on it, and I saw this thread. Didn't think to look at the date
    Hahaha. I have only been doing ASP.NET for 2 days now, am a complete beginner.

    Do you know much about form authentication?

    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