我正在将我的应用程序从Asp.Net MVC 5迁移到Asp.Net Core 2.2。如何在Asp.Net Core 2.2中获取登录的用户声明?
Asp.Net MVC 5代码:
export const requestNotifyPermission = () => {
try {
return Notification.requestPermission().then(function(result) {
return result;
});
} catch(err) {
console.warn('NotificationsAPI error: ' + err);
}
};
export const getCurrentNotifyPermission = () => {
// Possible values = default, granted, denied
try {
return Notification.permission;
} catch {
return 'denied';
}
};
export const createNotify = (title, body) => {
try {
if (getCurrentNotifyPermission() === 'granted') {
var options = {
body: body
};
return new Notification(title, options);
}
} catch(err) {
console.warn('NotificationsAPI error: ' + err);
}
}
Asp.Net Core 2.2代码:
var identity = new ClaimsPrincipal(User).Claims; //returns 141 claims
我希望Asp.Net Core 2.2应用程序可以返回141个索赔,但实际返回的索赔是75个。
---------------- Startup.cs文件-----------------
var identity = User.Claims.ToArray(); //returns 75 claims for same user id