Question After login-validation page is not directing to targeted page

eshack

Member
Joined
Jul 3, 2011
Messages
7
Programming Experience
Beginner
Dear sir,

I sucessfuly tested/debugged login page and it is directing to the page which is defined as start page(Students_add_1.aspx) in visual web developer 2008 express. But when testing it through IIS server that is http://localhost/westernsite the login id/name got validated but not starting the next page ie. stud..aspx. The screen is blank; (same when accessing through browser with IP address/westernsite) Here is my code:

<%@PageLanguage="VB" %>
<%
@ImportNamespace="System.Data" %>
<%
@ImportNamespace="System.Data.Common" %>
<%
@ImportNamespace="System.Data.SqlClient" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
scriptrunat="server">
Function ValidateUser(ByVal uid AsString, ByVal pwd AsString) AsBoolean
Dim sFirst, sName, sUser, sPwd, sLast AsString
Dim blnValidUser AsBoolean
Dim strConn AsString = ConfigurationManager.ConnectionStrings("WesternOnlineDBConnectionString").ConnectionString
Dim MySQL AsString = "Select [Name], [Login], " & _
"[Password] from Employees " & _
"Where Login=@uid AND Password=@Pwd"
Dim MyConn AsNew SQLConnection(strConn)
Dim objDR As SQLDataReader
Dim Cmd AsNew SQLCommand(MySQL, MyConn)
cmd.Parameters.Add(
New SQLParameter("@Uid", uid))
cmd.Parameters.Add(
New SQLParameter("@Pwd", pwd))
MyConn.Open()
Try
objDR = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
While objDR.Read()
sUser = objDR(
"login")
sPwd = objDR(
"Password")
sName = objDR(
"Name")
EndWhile
If sUser = ""And sPwd = ""Then
blnValidUser = "False"
Else
blnValidUser = "True"
Session("Name") = sName
EndIf
Catch ex As Exception
lblError.Visible =
"true"
lblError.Text = "Sorry Errors have occurred"
Finally
ValidateUser = blnValidUser
MyConn.Close()
'MsgBox(blnValidUser)
EndTry
EndFunction
</script>
<
scriptrunat="server">
Sub
doLogin(Source asObject, E as EventArgs)
If ValidateUser(txtUID.text,txtPWD.text) =TrueThen
FormsAuthentication.RedirectFromLoginPage(txtUID.text, False)
Else
lblError.Visible="True"
lblError.text="We're sorry, but the information you provided " & _
"does not match our database. Please try again."
EndIf
End
Sub
</
script>
<
htmlxmlns="http://www.w3.org/1999/xhtml">
<
headrunat="server">
<title></title>
</
head>
<
body>
<formid="form1"runat="server">
<div>
<table>
<tr>
<tdalign="Right"valign="Top"><b>User ID: </b></td>
<tdalign="Left"valign="Top">
<asp:TextBoxid="txtUID"
Runat="server"/>
</td>
</tr>
<tr>
<tdalign="Right"valign="Top"><b>Password: </b></td>
<tdalign="Left"valign="Top">
<asp:TextBoxid="txtPWD"
TextMode="Password"Runat="server"/>
</td>
</tr>
<tr>
<tdalign="Right"valign="Top"Colspan="2">
<asp:Buttonid="submitButton"
Text="Login"
onclick="doLogin"
Runat="server"/>
</td>
</tr>
</
table>
</div>
<asp:LabelID="lblError"runat="server"Text="Login Status:"></asp:Label>
<p>
 </p>
</form>
</
body>
</
html>



Please advise what correction should be done;

Thanks
 

eshack

Member
Joined
Jul 3, 2011
Messages
7
Programming Experience
Beginner
Yes I solved this problem: in iis server the default page was login.aspx ; so initialy it is directed to login.aspx after validation again it is directed to login.aspx as a caller; it is just a loop; instead of login.aspx I set default.aspx as default page in IIS; it was returned to this page after validation by login.aspx; Thanks
 
Top Bottom