通过ASP.Net中的用户登录创建配置文件页面 [英] Creating profile page by user login in ASP.Net

查看:132
本文介绍了通过ASP.Net中的用户登录创建配置文件页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的登录页面有用户名密码.当我第一次登录时,我重定向到创建个人资料页面,我必须提交我的个人资料,教育,技能等所有详细信息.提交这些详细信息后,我注销了.但是注销后,当我再次登录时,我必须重定向到我的主页,而不是再次重定向到 createprofile页面.

向我建议进一步登录重定向到首页的逻辑.
这是我用于登录 createprofile页面的代码:

Hi,
I have username and password for login page. When i login for first time, i redirected to createprofile page where i have to submit all my details of my profile,education,skill etc. After submitting these details i logged out. But after logged out when i again login i have to redirect to my home page not to again createprofile page.

Suggest me the logic to redirect to home page for further login.
Here is my code for login into createprofile page:

protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(str);
        SqlCommand cmd = new SqlCommand("select * from userlogin", con);
        con.Open();
        string decodpwd1 = DecodePassword(txtpwd.Text);
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            //Session["nm"] = txtuname.Text;
            //Session["uid"] = dr["user_id"].ToString();
            if (txtuname.Text == dr["user_name"].ToString() && decodpwd1 == dr["user_pwd"].ToString())
            {
               
                Response.Redirect("createprofile.aspx");
            }
            else
            {
                Label3.Visible = true;
                Label3.Text = "Invalid UserName/Password";
            }
        }

        con.Close();
        dr.Close();
    }

推荐答案

userlogin 表中保留一个字段为" IsProfileCreated "-默认值为``false''的位字段.

现在,一旦有人登录,请检查字段" IsProfileCreated "的值,如果发现错误,则直接进入配置文件更新页面.保存配置文件数据时,将此字段 IsProfileCreated 设置为true.因此,下一次当同一用户登录时,您将获得此字段中的数据,表明配置文件已设置,您可以将其重定向到其他位置.

示例代码:
Keep one field in your userlogin table as ''IsProfileCreated'' - a bit field with default value ''false''.

Now, once someone logins, check the value of the field ''IsProfileCreated'' and if found false direct to profile update page. On save of the profile data, set this field IsProfileCreated to true. Thus, next time when same user logs in, you have the data from this field that the profile is already set and you can redirect elsewhere.

Sample code:
if(!IsProfileCreated)
{
  // Direct to Profile update page
}
else
{
  // Direct to home page
}


在您的userlogin表中添加一列,告诉您从那里去哪里.
我将其设置为数字,并使用一个枚举,该枚举允许您稍后添加目标.

在登录页面中,您检查枚举并将用户发送到相应的页面-页面完成后,它将用将来的目标更新该列.

这还允许出现特殊消息,例如您的密码将很快过期",以此类推,您以后可能想要添加.
Add a column to your userlogin table which tells you where to go from there.
I would make it numeric, and use an enum, which allows you to add destinations later.

In your login page, you check the enum and send the user to the appropriate page - when teh page is then complete, it updates the column with the future destination.

This also allows for special messages, "your password will expire soon", and so forth that you may want to add later.


这篇关于通过ASP.Net中的用户登录创建配置文件页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆