Salut,

Je suis débutant en ASP .NET C#, et je l'utilise actuellement pour développer un site web. Dans la page d’accueil j'exige l’authentification des utilisateurs. J'ai tapé le code suivant dans mon fichier Accueil.aspx.cs mais ça ne matche pas.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
 
public partial class Accueil : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(" server=localhost; database=Admin_BDD ");
        try
        {
            con.Open();
            Console.WriteLine("Etat de la connection :" + con.State);
        }
        catch (Exception exp)
        { Console.WriteLine("L'errer suivante a été rencontrée: " + exp.Message);  }
 
        String cmdstr = "select count(*) from Admin_BDD where USER_NAME = '" + this.TextBoxNU.Text + "'";
        SqlCommand checkuser = new SqlCommand(cmdstr, con);
        int temp = Convert.ToInt32(checkuser.ExecuteScalar().ToString());
        if (temp==1)
        {
            string cmdstr2 = "select PASSWORD from Admin_BDD where USER_NAME='" + this.TextBoxNU.Text + "'";
            SqlCommand pass = new SqlCommand(cmdstr2, con);
            string password = pass.ExecuteScalar().ToString();
            if (password == TextBoxMDP.Text)
            {
                Session["New"] = TextBoxNU.Text;
                Response.Redirect("Gestion_FII.aspx");
            }
            else {
                Label1.Visible = true;
                Label1.Text = "Mot de passe incorrect..!!";
            }
        }
 
            else {
                Label1.Visible = true;
                Label1.Text = "Nom d'utilisateur incorrect..!!";
            }
        }   }
Est ce que quelqu'un peut m'aider pour résoudre ce problème
et merciiiiii d'avance