好的,所以我正在将webApi从aspnet转换为aspnetcore。
我在一篇HTTP文章中有以下内容。
var name = ControllerContext.RequestContext.Principal.Identity.Name;
widget.CreatedBy = name;
//Other properties
DataContext.Widgets.Add(entity);
我遇到的问题是RequestContext
在aspnetcore
中似乎不存在。我一直在寻找一天中最好的时间来寻找一个等价物。
在ASP中。NET核心,在控制器内这样做:
var claimsPrincipal = User;
参考:从ClaimsPrincipal迁移。当前