oidc User.Identity.Name 为空解决方法
public override Task TicketReceived(TicketReceivedContext context)
{
var result = base.TicketReceived(context); var identity = context.Principal.Identity as ClaimsIdentity;
if (identity != null)
{
// Add the Name ClaimType. This is required if we want User.Identity.Name to actually return something!
if (!context.Principal.HasClaim(c => c.Type == ClaimTypes.Name) &&
identity.HasClaim(c => c.Type == "name"))
identity.AddClaim(new Claim(ClaimTypes.Name, identity.FindFirst("name").Value)); // Check if token names are stored in Properties
if (context.Properties.Items.ContainsKey(".TokenNames"))
{
// Token names a semicolon separated
string[] tokenNames = context.Properties.Items[".TokenNames"].Split(';'); // Add each token value as Claim
foreach (var tokenName in tokenNames)
{
// Tokens are stored in a Dictionary with the Key ".Token.<token name>"
string tokenValue = context.Properties.Items[$".Token.{tokenName}"];
identity.AddClaim(new Claim(tokenName, tokenValue));
}
}
}
return result;
}
oidc User.Identity.Name 为空解决方法的更多相关文章
- ORACLE里怎么能判断一个日期类型的字段是否为空,解决方法:is null
ORACLE里怎么能判断一个日期类型的字段是否为空,解决方法:is null,解决方法:判断什么null都可以用is null.
- 【转】WebElement.getText()为空解决方法
WebElement.getText()为空解决方法 当使用getText()获取一个普通的链接文本时: <a href="http://www.baidu.com"> ...
- MVC5 Controller构造方法获取User为空解决方法
用如下方法获取UserId报空引用异常 public class BaseController : Controller { protected SiteContext db = new SiteCo ...
- mysqldump定时任务生成备份文件内容为空解决方法
1问题:写好了一个mysqldump备份脚本(如图)直接执行可以正常生成备份文件,但在用crontab运行时却生成内容为空 2原因分析:由于mysqldump存在于全局环境变量mysql的bin下面, ...
- json解析出来数据为空解决方法
从APP端或从其他页面post,get过来的数据一般因为数组形式.因为数组形式不易传输,所以一般都会转json后再发送.本以为发送方json_encode(),接收方json_decode(),就解决 ...
- selenium中WebElement.getText()为空解决方法
当使用getText()获取一个普通的链接文本时: <a href="http://www.baidu.com">baidu</a> 如果得到的文本只为空, ...
- Centos 6.4 /usr/src/kernels 目录为空解决方法
/usr/src/kernels 目录下是Linux的内核源码,如果其为空,则需要安装安装 kernel-headers 和 kernel-devel包
- MySQL data路径为空解决方法
CMD x:\mysql\5.7.12\bin>mysqld --initialize-insecure --user=mysql
- session在本地可以正常使用,而在sae上却无法使用或者值为空的解决方法
session在本地可以正常使用,而在sae上却无法使用或者值为空的解决方法: session_start()放在当前页代码的第一行即可解决该问题. 在本地上session_start()如果不是放在 ...
随机推荐
- Wincc用户登录VBS脚本
在Wincc中为防止未知用户的误操作,在操作性按钮以及图符等设备操作面板,在组流程图时,需设置用户权限,只有符合权限的用户才可以进行操作.所以在流程图界面需设置系统用户登录界面.登录操作可以选择按钮或 ...
- Spring cloud系列之win10 下安装 ZooKeeper 的方法
ZooKeeper 下载地址: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 1.将下载的文件解压到指定的目录中 2.进入conf文件夹 ...
- JPEG
JPEG文件由八个部分组成,每个部分的标记字节为两个,首字节固定为:0xFF,当然,准许在其前面再填充多个0xFF,以最后一个为准.下面为各部分的名称和第二个标记字节的数值,用ultraedit的16 ...
- Python 同一文件中,有unittest不执行“if __name__ == '__main__”,不生成HTMLTestRunner测试报告的解决方案
1.问题:Python中同一个.py文件中同时用unittest框架和HtmlReport框架后,HtmlReport不被执行. 2.为什么?其实不是HtmlReport不被执行,也不是HtmlRep ...
- [Leetcode 90]求含有重复数的子集 Subset II
[题目] Given a collection of integers that might contain duplicates, nums, return all possible subsets ...
- mysql 在 win 安装 最全攻略(附转载的乱码终极解决方案)以及解决data too long for column 'name' at row 1, 一种可能就是因为编码一致性问题.
[博客园cnblogs笔者m-yb原创,转载请加链接,公众号aandb7, github.com/mayangbo666,QQ群927113708] https://www.cnblogs.com/m ...
- eclipse导入git项目出现There are no resources that can be added or removed from the server错误
上传到git上的项目因为配置了过滤文件,将.settings文件和.project文件都过滤掉了,settings文件中主要存放的是各种插件配置,约束你可以更好的利用IDE进行编码 因为将这两个文件过 ...
- 《JavaScript Dom 编程艺术》读书笔记-第7章
动态创建标记~内容包括: 1. 传统技术:document.write 和innerHTML 2. 深入剖析DOM方法:createElemen.createTextNode.appendChild和 ...
- 容器的注入和container设计的思想——Injection Container 理解
为什么会出现容器的注入? 容器:顾名思义,装东西的器物. 至于spring中bean,aop,ioc等一些都只是实现的方式:具体容器哪些值得我们借鉴,我个人觉得是封装的思想.将你一个独立的系统功能放到 ...
- Spring Boot 简单小Demo 转载!!!
Spring Boot简介 接下来我们所有的Spring代码实例将会基于Spring Boot,因此我们先来了解一下Spring Boot这个大杀器. Spring早期使用XML配置的方式来配置Spr ...