• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

ASP.NET - Login control

hello,
i have in one asp.net web form a login control.
in the loggedin event, i am calling one vb sub.
Can someone tell me why the sub in executing twice??
thanks
0
Nyana22
Asked:
Nyana22
  • 4
  • 3
1 Solution
 
spprivateCommented:
Can you post the code
Both html and code behind
0
 
Nyana22Author Commented:
Please, find the code from 3 files,
asp.net
vb
class.vb
thanks
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Login ID="Login1" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4"
        BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" Font-Names="Cambria" Font-Size="9pt"
        ForeColor="#333333" Height="64px" RememberMeText="Remember me"
        Style="z-index: 100; left: 434px; position: absolute; top: 210px" Width="189px">
        <CheckBoxStyle BackColor="Transparent" Font-Names="cambria" Font-Overline="False"
            Font-Size="9pt" />
        <TextBoxStyle Font-Size="0.8em" />
        <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
            Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
        <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
        <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
    </asp:Login>
    <asp:Button ID="Button1" runat="server" Style="z-index: 101; left: 483px; position: absolute;
        top: 150px" Text="Button" />
    <asp:Label ID="Label1" runat="server" Style="z-index: 103; left: 571px; position: absolute;
        top: 158px" Text="Label"></asp:Label>
</asp:Content>
==========================================================================
 
 
Imports getstwsSP
Imports System.Security.Authentication
Partial Class Login
    Inherits System.Web.UI.Page
 
 
    Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoginError
        getstwsSP.updaterLogin(Login1.UserName.ToString, Request.UserHostAddress.ToString, 0)
    End Sub
 
    Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
        getstwsSP.updaterLogin(Login1.UserName.ToString, Request.UserHostAddress.ToString, 1)
    End Sub
End Class
 
==========================================================================
Imports Microsoft.VisualBasic
Imports System.Data
Imports MySql.Data.MySqlClient
Imports ConnectionManager
 
Public Class getstwsSP
    Public Shared Sub updaterLogin(ByVal userName As String, ByVal ipAdrr As String, ByVal logStatus As Int16)
 
        ' C'est la valeur numerique qui doit etre affecter par le retour de la procedure stockee, et qui doit etre retourne a l'appel de la fonction
 
        Dim con As MySqlConnection
        con = ConnectionManager.getConnexion
 
        ' Declaration de l'objet MySQLcommand, celui la prend la connexion a la BD, cherche la procedure a executer et la fournit les parametres de la fonction
        Dim sqlCmd As New MySqlCommand
 
        ' L'objet commande MySQL doit executer la procedure stockee ds la BD
        sqlCmd.CommandText = "upLogin"
        sqlCmd.CommandType = CommandType.StoredProcedure
 
        ' Declaration et instanciation d'objet parametres
        ' Ces dernier sont responsable a acheminer les valeur des parametre de la fonction au parametre de la procedure stockee ds la BD.
        Dim userP As New MySqlParameter("?userParam", MySqlDbType.VarChar, 25)
        Dim ipP As New MySqlParameter("?ipParam", MySqlDbType.VarChar, 45)
        Dim logStatP As New MySqlParameter("?LoginStatus", MySqlDbType.Int16, 1)
 
        ' Affectation des valeurs des parametre qui vont etre passes a la SP, par les valeur d'entree de la fonction
        userP.Value = userName
        ipP.Value = ipAdrr
        logStatP.Value = logStatus
 
        ' Ajouter les objets parametre a l'objet MySQL command
        sqlCmd.Parameters.Add(userP)
        sqlCmd.Parameters.Add(logStatP)
        sqlCmd.Parameters.Add(ipP)
 
        ' Ajouter la connexion a la BD a l'objet MySQL command
        sqlCmd.Connection = con
 
        ' Demander a l'objet MySQL command d'executer la SP et de retourner sa valeur unique de retour et de l'affecter 
        ' a la variable aa
        sqlCmd.ExecuteNonQuery()
 
        ' Demander a la fonction que sa valeur de retoure soit celle de la variable aa, qui elle est la valeur de retour de ls SP grace a l'objet MySQL command
        ' Fermer la connexion a la BD
        con.Close()
    End Sub
End Class

Open in new window

0
 
spprivateCommented:
I mean your Login.aspx.vb file please
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Nyana22Author Commented:

Imports getstwsSP
Imports System.Security.Authentication
Partial Class Login
    Inherits System.Web.UI.Page
 
 
    Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoginError
        getstwsSP.updaterLogin(Login1.UserName.ToString, Request.UserHostAddress.ToString, 0)
    End Sub
 
    Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
        getstwsSP.updaterLogin(Login1.UserName.ToString, Request.UserHostAddress.ToString, 1)
    End Sub
End Class

Open in new window

0
 
spprivateCommented:
Am not seeing anything wrong.Typically if you have the event wired in both places (html as well as code behind) you get this issue.But in your case I dont see that way.
How are you saying it is firing twice.Are you getting two records inserted?
Put a break point and see
0
 
Nyana22Author Commented:
yes i am getting 2 record inserted, i have a field in the table that is the time, witch has always the same value in the 2 records inserted.
Where i put a break point?
0
 
spprivateCommented:
What was the issue?How did you solve it
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now