Search code examples
asp.net-identityconsole-applicationclass-library

How to access User.Identity.GetUserId() in Class library


I am going to use a class library as a data layer in my mvc.net web application. Is it possible to access User.Identity.GetUserId() from within the class library.

I can access username by using HttpContext.Current.User.Name but not UserId.

Meanwhile, Microsoft.Aspnet.Identity reference is not accessible in class library project.

thanks


Solution

  • Just added Microsoft.AspNet.Identity.Core.dll to my console application references. Unfortunately this reference does not exist in list of References nor in Extensions. I borrowed it from my web application's bin folder. I'm wondering why Microsoft has not added this in the list of references!