Last post Jun 20, 2017 01:12 PM by hkbeer
Jun 16, 2017 11:17 AM|hkbeer|LINK
I just implemented OWIN on my web form so people can use Google or Microsoft to login.
I watch the whole process and exam the log database.
I was surprised to find once they supply their own Google/Ms ID and password,
they will be asked to supply an alias, and after login
the UserName field of my database is ALIAS (!!), instead of their google account name.
So this defeated my original purpose of verifying they are the one I intend.
I already know their specific emails so I want to see it is their email account being logged, not their arbitrary alias.
Alias is not able to identify the login is the email holder....
Please help... what can I do ?
Even it cannot fix at the point the ASPnetUser DB table use name field,
is there way for us to get their email into label1.text after login ?
When Login with MS account it says site can get his email, age, profile etc.
I do not need their real name profile etc.
I only need to get his email account name (eg if his email is
email@example.com, I want to fetch abcdef into label1, how ?
Thanks a lot.
Jun 19, 2017 09:13 AM|Eric Du|LINK
According to your description, as far as I know, you want to login with the facebook, google's account in your website, then you want to get the use's username, please try the following code to get the specify user name:
var identity = (ClaimsIdentity)HttpContext.User.Identity;
var name = identity.Claims.FirstOrDefault(m => m.Type == System.Security.Claims.ClaimTypes.Name).Value;
For more details, please check the following document:
Jun 19, 2017 01:30 PM|hkbeer|LINK
Thanks a lot. I get missing namespace and assembly due to ClaimsIdentity
What should I do ? I am quite unfamiliar with creating class etc please help on teaching me the preparation work before I could use this code.
and where should I put this code ? In page load event ?
I am using Web Form and not MVC.
Jun 20, 2017 01:12 PM|hkbeer|LINK
Dear all, anyone kind to tell how to use this code in my Web Form ?
Thanks so much. I am done only just this pending for my whole app. Pls help...
Where to put and what I need to prepare to successfully get the values on the right to the variables on the left ?
I get intellisense warning about ClaimsIdentity in the 1st line saying Namespace or Assembly is missing.