redirection from the Login Page



Hi EveryBody:

I face problme in my web application that made by ASP.Net the code behined
is Vb.Net.

The problem is insated of using the App_Data folder in the solution explorer
I used mu own Database that located into my machin which is the local host.

I used create user wizerd to creat the user and I made the connection tom
the database to safe the user name and password inside it the process work
well and.

But when I want to retrive the data from the database to make the
authentication I make the connection to the data base and I check from the
username and password but the only proble do I have is that the Destination
URL is alway going to the Login.aspx and faulier action takedplace and
faulier message I recived.

This is my connection in the web.confug:

<connectionStrings>
<add name="husamConnection" connectionString="Data
Source=localhost;Initial Catalog=Husam;Persist Security Info=True;Integrated
Security=SSPI" providerName="System.Data.SqlClient"/>
</connectionStrings>

and my code is:

<%@ IMPORT Namespace ="System.Data" %>
<%@ IMPORT Namespace ="System.Collections" %>
<%@ IMPORT Namespace ="System.Collections.Generic" %>
<%@ IMPORT Namespace ="Microsoft.VisualBasic" %>
<%@ IMPORT Namespace ="System.Data.SqlClient" %>
<%@ IMPORT Namespace ="Microsoft.SqlServer.Management.Common" %>
<%@ IMPORT Namespace ="Microsoft.SqlServer.Management.Smo" %>

<SCRIPT runat="server">

Function SiteSpecificAuthenticationMethod(ByVal UserName As String,
ByVal Password As String) As Boolean
Dim cmd As SqlCommand
Dim scon As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("husamConnection").ConnectionString)
Dim sql As String
Dim rawan As New List(Of String)
Dim rawan1 As New List(Of String)
Try
scon.Open()
sql = "SELECT user_Name,user_Password FROM husam_Tab"
cmd = New SqlCommand(sql, scon)
cmd.ExecuteNonQuery()
Dim myReader As SqlDataReader = cmd.ExecuteReader()
While (myReader.Read())
rawan.Add(myReader.GetString(0))
rawan1.Add(myReader.GetString(1))
End While
myReader.Close()
scon.Close()
If rawan.Contains(UserName) Then
If rawan1.Contains(Password) Then
MsgBox("welcom to access")
Response.Redirect("~/MemberShipFolder/MemberArea.aspx",
True)
'Login1.DestinationPageUrl =
"~/MemberShipFolder/MemberArea.aspx"
Else
Login1.FailureText = "Your password is not correct"
'Login1.FailureAction = LoginFailureAction.Refresh
End If
Else
MsgBox("Your user name is not correct")
End If
Catch ex As Exception
End Try
Return False
End Function

Sub OnAuthenticate(ByVal sender As Object, ByVal e As
AuthenticateEventArgs)
Dim Authenticated As Boolean
Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName,
Login1.Password)
e.Authenticated = Authenticated
End Sub
</SCRIPT>
.



Relevant Pages

  • Re: ExecuteReader requires an open and available Connection.
    ... you have ALL your users sharing one connection. ... Public Shared Function GetServerAs String ... Dim theServer As String ...
    (microsoft.public.dotnet.framework.aspnet)
  • DTS Transformation Data Task Errors
    ... Dim oIniFile As New IniFile ... Dim sServerName As String = oIniFile.GetString("Source Connection", ... ;ServerName* - String value representing the name or ip address of the ...
    (microsoft.public.sqlserver.dts)
  • Re: ExecuteReader requires an open and available Connection.
    ... you have ALL your users sharing one connection. ... Public Shared Function GetServerAs String ... Dim theServer As String ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: making datareaders
    ... ''' This is set in the connection string by setting the ... Dim myAddressReader As SqlDataReader ... Dim myFinalString As String = "" ...
    (microsoft.public.dotnet.languages.vb)
  • Re: making datareaders
    ... You have to close the datareader when you are done with it, or the connection won't be usable again. ... ''' This is set in the connection string by setting the ... Dim myAddressReader As SqlDataReader ... Dim myFinalString As String = "" ...
    (microsoft.public.dotnet.languages.vb)