Click here to Skip to main content
15,890,506 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: how to make session secure? Pin
RajpootRohan25-Mar-09 21:35
professionalRajpootRohan25-Mar-09 21:35 
GeneralRe: how to make session secure? Pin
anilpal25-Mar-09 22:35
anilpal25-Mar-09 22:35 
GeneralRe: how to make session secure? Pin
RajpootRohan25-Mar-09 22:56
professionalRajpootRohan25-Mar-09 22:56 
GeneralRe: how to make session secure? Pin
N a v a n e e t h25-Mar-09 23:14
N a v a n e e t h25-Mar-09 23:14 
GeneralRe: how to make session secure? Pin
RajpootRohan25-Mar-09 23:19
professionalRajpootRohan25-Mar-09 23:19 
GeneralRe: how to make session secure? Pin
N a v a n e e t h25-Mar-09 23:31
N a v a n e e t h25-Mar-09 23:31 
GeneralRe: how to make session secure? Pin
RajpootRohan25-Mar-09 23:35
professionalRajpootRohan25-Mar-09 23:35 
GeneralRe: how to make session secure? Pin
RajpootRohan26-Mar-09 2:11
professionalRajpootRohan26-Mar-09 2:11 
N a v a n e e t h wrote:
Hash it. Passwords stored as plain text is not secure. Better method is to hash the password and store the computed hash in database. When user enters password for authentication, has it and compare the hash with the value stored in DB. System.Security.Cryptography[^] got many classes to work with. Check SHA[^] implementation.


Hi,
As you suggested I did it but login is not working. I did like this.

protected void Button1_Click(object sender, EventArgs e)
{
    string pwd = Txtpassword.Text.Trim();
    string hashpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "SHA1");
    //SqlConnection con = new SqlConnection("Server=.; Database=eclsc; Trusted_Connection=yes");
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandText = "Select userid,username,password,first_name from USERS where username=@username and password=@password";

    cmd.Parameters.Add("@username", SqlDbType.NVarChar, 50).Value = Txtusername.Text.Trim();
    cmd.Parameters.Add("@password", SqlDbType.NVarChar, 50).Value = hashpwd;

    try
    {
        cmd.Connection.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while(rdr.Read())
        {
            //string x = (rdr["password"]).ToString();
            uid = (rdr["userid"]).ToString();
            fname = (rdr["first_name"]).ToString();
            uname = (rdr["username"]).ToString();
            Session["uname"] = uname;
            Session["userid"] = uid;
            if (uname != null)
            {
                //Change the Session called "Logged" value into "Yes"
                Session["Logged"] = "Yes";

                //Store the Username in one of the Sessions, so it can be used later
                Session["User"] = fname;

                //Redirect to the requested page
                //If there is no requested page, then it will be redirected to the Default.aspx WebForm
                Label6.Text = (Session["URL"]).ToString();
                Response.Redirect(Label6.Text);
            }
            else
            {

            }
        }
    }
    catch (SqlException se)
    {
        Lblmsg.Text = se.Message;
    }
    catch (Exception ee)
    {
        Lblmsg.Text = ee.Message;
    }
    finally
    {
        cmd.Connection.Close();
    }
}


PLease assist me..

cheers,
sneha

GeneralRe: how to make session secure? Pin
anilpal26-Mar-09 2:46
anilpal26-Mar-09 2:46 
GeneralRe: how to make session secure? Pin
RajpootRohan26-Mar-09 3:09
professionalRajpootRohan26-Mar-09 3:09 
GeneralRe: how to make session secure? Pin
anilpal26-Mar-09 3:31
anilpal26-Mar-09 3:31 
GeneralRe: how to make session secure? Pin
anilpal26-Mar-09 3:34
anilpal26-Mar-09 3:34 
GeneralRe: how to make session secure? Pin
RajpootRohan26-Mar-09 19:28
professionalRajpootRohan26-Mar-09 19:28 
GeneralRe: how to make session secure? Pin
RajpootRohan26-Mar-09 19:45
professionalRajpootRohan26-Mar-09 19:45 
QuestionASP Pages are not running in .net 1.1Application Pin
yadlaprasad25-Mar-09 21:05
yadlaprasad25-Mar-09 21:05 
AnswerRe: ASP Pages are not running in .net 1.1Application Pin
anilpal25-Mar-09 21:33
anilpal25-Mar-09 21:33 
GeneralRe: ASP Pages are not running in .net 1.1Application Pin
yadlaprasad25-Mar-09 21:47
yadlaprasad25-Mar-09 21:47 
GeneralRe: ASP Pages are not running in .net 1.1Application Pin
anilpal25-Mar-09 22:37
anilpal25-Mar-09 22:37 
QuestionDrop Down Lists Pin
scar_face25-Mar-09 20:47
scar_face25-Mar-09 20:47 
AnswerRe: Drop Down Lists Pin
anilpal25-Mar-09 22:45
anilpal25-Mar-09 22:45 
GeneralRe: Drop Down Lists Pin
scar_face25-Mar-09 23:01
scar_face25-Mar-09 23:01 
GeneralRe: Drop Down Lists Pin
anilpal25-Mar-09 23:15
anilpal25-Mar-09 23:15 
GeneralRe: Drop Down Lists Pin
scar_face25-Mar-09 23:29
scar_face25-Mar-09 23:29 
GeneralRe: Drop Down Lists Pin
anilpal26-Mar-09 2:54
anilpal26-Mar-09 2:54 
QuestionRewrite Url on page post Back Pin
amit sahu2025-Mar-09 20:34
amit sahu2025-Mar-09 20:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.