我正在尝试从中提取电子邮件地址,HttpContext.User.Claims并且希望寻求帮助,以找到一种更好的方式对此进行编码(也许使用LINQ?)我现在的操作方式似乎很琐。var userClaimsList = HttpContext.User.Claims.ToList();// List is of varying length but email is always 3rd from the bottom.int emailPosition = userClaimsList.Count()-3; string searchString = "preferred_username: "; // dirtyEmail = "preferred_username: xyz@emailcom"string dirtyEmail = userClaimsList[emailPosition].ToString();string cleanEmail = dirtyEmail.Replace(searchString, "").ToLower().Trim();我尝试了另一篇文章中推荐的LINQ解决方案,但收到错误消息Operator == cannot be applied to operands of type 'Claim' and 'string'。
2 回答
- 2 回答
- 0 关注
- 1294 浏览
添加回答
举报
0/150
提交
取消