redirection from the Login Page


G

Guest

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>
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top