我遇到一些奇怪的行为。
运行这段代码时:
var foo = await actionContext.RequestContext?.Principal?.ToUserTokenAsync() ?? UserToken.UnidentifiedUser;
Principal是null在运行时,我得到一个空引用异常。
Principal
null
为什么它不只是返回-> UserToken.UnidentifiedUser?
UserToken.UnidentifiedUser
c# null-coalescing-operator async-await
async-await ×1
c# ×1
null-coalescing-operator ×1