There are three authentication methods in ASP. NET. When one of them is used to verify the current user and pass the verification, a verification ticket must be saved between the server and the client to save the verification information .. NET provides an iidentity-like interface to complete this function. Please note that context. User is an iprincipal interface, while identity isIidentityType interface. There are four typesFormsidentity genericidentity passportidentity windowsidentityImplementedIidentityInterface. These types correspond to several verification modes of. net. The above is basically nonsense, just a bit. However, let's take a look at the above, and then find the ASP. NET Forms authentication article on msdn. Take a look at the use of the formsidentity class during Forms authentication. Some information is saved to the instance of the formsidentity class.Context. User. Identity. NameExtracted. |
You can write as follows:
On the logon page:
After the password is verified: formsauthentication. redirectfromloginpage (yourname. Text, false );
On the targeted page:
String getname = user. Identity. Name;
Let's take a look at the SDK's example of "form-based authentication" for security.
To assign a session value to user. Identity. Name, you can assign the number. Text value to the session on the login page.
Haha, a security question.
You can use your own class to put it in user. Identity. Context. User. Identity. name indicates the name of the current user. You can put anything you want. Note that you can use the following code:
Httpcontext. Current. User = new genericprincipal (object, "");
Object is your own defined class.
__________________________________
Context. User. Identity. Name Description
// Thanks to Baidu, my hy mentor, my senior brothers, younger siblings, and younger sisters. Thanks to Chairman Mao, thank Jesus Christ, thank you for silence, and thank you for harmony. Today, I made an identity verification page, which basically implements functions, but cannot display the name of the current user. I got nothing in msdn for a long time. The problem lies in context. User. Identity. Name; context isHttpcontextClass, the user property gets or sets security information for the current HTTP request, and then check whether the identity isIidentityType interface; name is its public properties, which can be gets The name of the current user. There is still a solution. The online prawns said they were about the verification method. They knew the form method and added it to Web. cofig. Let's get it done !!!! /////////////// // You can share your network resources with others. (1) There are three authentication methods in ASP. NET. When one of them is used to verify the current user and pass the verification, a verification ticket must be saved between the server and the client to save the verification information .. NET provides an iidentity-like interface to complete this function. Please note that context. User is an iprincipal interface, while identity isIidentityType interface. There are four typesFormsidentity genericidentity passportidentity WindowsidentityImplementedIidentityInterface. These types correspond to several verification modes of. net. The above is basically nonsense, just a bit. However, let's take a look at the above, and then find the ASP. NET Forms authentication article on msdn. Take a look at the use of the formsidentity class during Forms authentication. Some information is saved to the instance of the formsidentity class.Context. User. Identity. NameExtracted. (2) Context. User. Identity. Name is always empty. Why do you want to learn from your fingers? ______________________________________________________________________________________________ Answer 1: Are you using forms-based authentication or Windows integrated authentication? ______________________________________________________________________________________________ Answer 2: You change Asp.net to Windows built-in verification, and context. User. Identity. name has a value. ______________________________________________________________________________________________ Answer 3: Up Attached: Web. config // only solves this problem. <System. Web> <Authentication mode = "forms"> </System. Web> |