How do you get a User Identity?

后端 未结 2 1155
暖寄归人
暖寄归人 2021-01-17 05:33

Once a user is authenticated and authorized, the application can get information about the user by using the User object’s Identity property. The Identity property returns a

2条回答
  •  情书的邮戳
    2021-01-17 06:13

    Please clarify if you are wanting something like the following below..

    If you just want the users Identity.. from an ASP.NET WebPage when the Page_Load is called create a string[] and do something like the following

    string strRawUser = Page.User.Identity.Name;
    

    Then from there strRawUser will have something like "DomainName\UserName" So you need to Split the string into an stringArray and get the string[1] value like this

    string[] strRawUserSplitter = Page.User.Identity.Name.Split("\\");
    Label2.Text = strRawUserSplitter[1]
    

提交回复
热议问题