在.Net Core因為沒參考System.Web
可改用ReturnTrue.AspNetCore.Identity.Anonymous
Startup.cs加入
app.UseAnonymousId();取得方式
IAnonymousIdFeature feature = HttpContext.Features.Get<IAnonymousIdFeature>(); string anonymousId = string.Empty; if (feature != null) { anonymousId = feature.AnonymousId; }參考資料
Git Hub AnonymousId
ReturnTrue.AspNetCore.Identity.Anonymous