Home > Net >  In c # asp.net how to display the user's personal information after login
In c # asp.net how to display the user's personal information after login

Time:11-21

According to the information in the registration has been stored in the database before,

CodePudding user response:

If you are a MVC User. Identity. The Name
If you did not use forms authentication, but write their own, so the Request, Session (" username "). The ToString () if you use the username as key storage username

CodePudding user response:

reference 1/f, guiyang horse Ma Shanfu plugging waterproof engineering professional maintenance of swimming pool response:
. If you are a MVC User Identity. The Name
If you did not use forms authentication, but write their own, so the Request, Session (" username "). The ToString () if you use the username as key storage username
what other data show that this user? For instance in the database of his gender, email, etc...

CodePudding user response:

According to the user, to read relevant information database, and then display the page

CodePudding user response:

reference stami reply: 3/f
according to the user, to read relevant information database, and then display the page
code should be what kind of? I didn't set the cs, use code database connection

CodePudding user response:

Have you ever learn to use the Session?
If not, learn the session, the problem is solved.

CodePudding user response:

Many cache session cookie can achieve ha, you baidu, one session cookies are all simple ways of implementation

CodePudding user response:

You may save a front-end js directly to the user object

CodePudding user response:

reference 5 floor is nu month god reply:
have you ever learn to use the Session?
If not, learn the session, the problem is solved,
ok, I'll see if the

CodePudding user response:

refer to 6th floor rabbit family - second brother reply:
many cache session cookie can achieve ha, you baidu, in which the session cookies are relatively simple implementation way
ok, I go and see

CodePudding user response:

The login. Aspx. Cs
 
Var user=userbll. Login (request [name], the request (PWD));
If the user==null
Alert (logon failure)
The else
//"todo" landing successful
The session (" user "]=user;
Resp. Redic (" main aspx ");


Userbll. Cs

 
Public user login (string name, string PWD)
{
The user u=null;
Var SQL="select * from the user where the username=" + name + 'and PWD=' + PWD.
Var. Dr=sqlhelper executedr (SQL);
If Dr. Read ()
U=new user ();
U.a ge=Dr [r]. "age" tostring (),
The return of u;
}



The main. Aspx

 
Void pageload (obj, evenet)
{
If the session (" user ")==null
Alert (not log in can't use)
Resp. Redic (" login. Aspx ")
The else
Var u=session (" user ") as a user;
Alert (welcome back + u.u sername);
}

CodePudding user response:

Can I use session to store user name and display, but through the user name in the database query and show other information code how to play? Thank you brothers

CodePudding user response:

Simply use session to store user other information directly and deposit method is equivalent to a user name,
  •  Tags:  
  • C#
  • Related