Question

The problem seems so ridiculous. I am trying to get the id of current logged in user here but get error "The type or namespace name 'User' does not exist in the namespace 'Microsoft.AspNet.Identity' (are you missing an assembly reference?) if I try to access Microsoft.AspNet.Identity.User.GetUserId(); Other properties of the namespace are accessable as you can see here.

Screenshot

I have installed following packages in current project.

Screenshot

Has accessing current user changed in Identity 2.0.1? I have looked at ASP.NET MVC 5 - Identity. How to get current ApplicationUser and from that question this should work. Did not see other properties that would mean the same thing.

The rest of the functionality (creating users, signing in, etc) is working fine. Have been banging my head against the wall for hours. Any help would be appretiated. Thanks.

Was it helpful?

Solution

Since you seem to do better with pictures... Here is the solution.

NOTE:, you don't pass anything as a parameter, because this is an extension method. Notice the "this" in the parameter list, that's a big clue. Also notice the icons with the arrow pointing down next to the method name, that also indicates that it's an extension method.

enter image description here

OTHER TIPS

You should probably be using this: Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(). Have a look at the accepted answer on this SO post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top