Ask a Question related to ASP.NET Security, Design and Development.
-
Rudy #1
NEWBIE ? about Form Authenticity
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
Rudy Guest
-
Newbie having problem with form
Hello I am very new at flash but have managed to put form inputs on my webpage.. you can view here www.puppypalacedaycare.com/bookparty.html I am... -
newbie can't get form working
Please help. What am I doing wrong? I can't get the value entered into text.html to be seen in text.php. Thnaks in advance, Raj ... -
newbie form authentication
I was thinking of using form authtentication. Is it a pain, or should I do it? Also, I want login to redirect to one of two pages always, no... -
Certificate of Authenticity
How can I get a lost Certificate of Authenticity? -
(newbie) from form to table. ?
Thanks Dirk. It did the job. there was a missing " there behind the VALUE I have another Question. Now i have my forms .. inputting onto on...



Reply With Quote

