Home Ask Login Register

Developers Planet

Your answer is one click away!

kirsten g February 2016

'ClaimsPrincipal' does not contain a definition for 'GetUserId'

Some time ago, I created a project using the ASP.Net 5 web application template. I recall the project built at the time.

Now when I try and build an old project I created I have the error

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'ClaimsPrincipal' does not contain a definition for 'GetUserId' 
and no extension method 'GetUserId' accepting a first argument of type 'ClaimsPrincipal' could be found
 (are you missing a using directive or an assembly reference?)  KGWebsite.DNX 4.5.1, KGWebsite.DNX Core 5.0 
E:\EShared\Dev2016\KG.Website\KGWebsite\src\KGWebsite\Controllers\Web\ManageController.cs   291 Active

When I create a new project from scratch using he same template, the new project will build. I am having problems troubleshooting the difference between the two projects.

Both use DNX4.5.1 which shows in the solution explorer as having a reference to Microsoft.AspNet.Identity ( 3.0.0-rc1-final)

When I drill into the metadata for Microsoft.AspNet.Http in the working copy I have

#region Assembly Microsoft.AspNet.Http.Abstractions, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60
// C:\Users\kirsten\.dnx\packages\Microsoft.AspNet.Http.Abstractions\1.0.0-rc1-final\lib\net451\Microsoft.AspNet.Http.Abstractions.dll

In the non working copy I have

#region Assembly Microsoft.AspNet.Mvc.ViewFeatures, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60
// C:\Users\kirsten\.dnx\packages\Microsoft.AspNet.Mvc.ViewFeatures\6.0.0-rc1-final\lib\net451\Microsoft.AspNet.Mvc.ViewFeatures.dll

What steps should I be taking to correct the project that is not working?


Sam Farajpour Ghamari February 2016

GetUserId() method is a extension method which is implemented in System.Security.Claims namespace. So to use the method simply add the namespace in your class:

using System.Security.Claims;

Post Status

Asked in February 2016
Viewed 1,687 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life