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=1.0.0.0, 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
#endregion
In the non working copy I have
#region Assembly Microsoft.AspNet.Mvc.ViewFeatures, Version=6.0.0.0, 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
#endregion
What steps should I be taking to correct the project that is not working?
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With