redirection from the Login Page

Discussion in 'ASP .Net Security' started by Husam, May 26, 2007.

  1. Husam

    Husam 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>
    Husam, May 26, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VEIDEMANIS

    Login based Site redirection

    VEIDEMANIS, Jun 19, 2006, in forum: HTML
    Replies:
    4
    Views:
    451
  2. =?Utf-8?B?SHVzYW0=?=

    redirection from the Login Page

    =?Utf-8?B?SHVzYW0=?=, May 26, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    324
    =?Utf-8?B?SHVzYW0=?=
    May 26, 2007
  3. Shannon

    login page stays on login page

    Shannon, Jan 9, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    522
    Shannon
    Jan 9, 2008
  4. Crouchie1998

    Login Redirection

    Crouchie1998, Sep 24, 2010, in forum: ASP .Net
    Replies:
    0
    Views:
    331
    Crouchie1998
    Sep 24, 2010
  5. Mike
    Replies:
    0
    Views:
    165
Loading...

Share This Page