Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > NEWBIE ? about Form Authenticity

Reply
Thread Tools

NEWBIE ? about Form Authenticity

 
 
Rudy
Guest
Posts: n/a
 
      01-09-2005
Hello all!

I have a simple login page, but I get a "Object reference not set to an
instance of an object" error. But I only get the error when I put in a user
and a password from the user databse in SQL. When I put in a non-user name,
my little error message comes up like it should, and it wors fine. Here is
my code:

Function ValidateUser(ByVal uid As String, ByVal passwd As String) As
Boolean
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim dr As SqlDataReader
Dim retVal As Boolean = False
cnn = New SqlConnection("Server=localhost;" & _
"DataBase=IMS;" & "Integrated Security=SSPI")
cmd = New SqlCommand("Select * from users where uname = '" & uid &
"'", cnn)
cnn.Open()
dr = cmd.ExecuteReader
While (dr.Read())
If StrComp(dr.Item("Pwd"), passwd, 1) = 0 Then
retVal = True
End If
End While
cnn.Close()
ValidateUser = retVal

End Function
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Session("LogonID") = txtUser.Text
Session("Password") = txtPswd.Text

Dim strID As String
Dim strPwd As String

strID = txtUser.Text
strPwd = txtPswd.Text

If ValidateUser(strID, strPwd) Then
"""" If Session("LoginID").ToString = String.Empty Then""""
Session("LoginID") = strID
Session("Password") = strPwd

FormsAuthentication.RedirectFromLoginPage(strID, False)

End If
Else
lblError.Text = "Invalid Login User/Password."

End If


End Sub

Private Sub Submit1_ServerClick(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Submit1.ServerClick
Session("LogonID") = txtUser.Text
Session("Password") = txtPswd.Text

FormsAuthentication.RedirectFromLoginPage(txtUser. Text, False)

End Sub
End Class
The error I'm getting is getting tagged at this line "If
Session("LoginID").ToString = String.Empty Then" I put a few quoted around
it in the code so it's easy to see.
I know I'm doing something wrong, not sure what.

Thanks for the help!!!

Rudy
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve form field value if form is EncType=multipart/form-dataForm? Li Zhang ASP .Net 4 02-27-2009 01:23 AM
<form>...</form> - how to supress blank space after </form> in IE? rob c Javascript 4 12-30-2005 01:18 PM
vs2005 - Open a child form based on selected record parent form's dgv - how? dbuchanan ASP .Net 2 12-19-2005 10:52 PM
macromedia 7 install authenticity warning??? Barn owl Computer Information 2 04-02-2004 07:31 PM
How get replacement certificate of authenticity/product code? David Computer Support 8 09-14-2003 03:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57