locked
Problem with Claims Principal properties in Visual Studio 2017 RRS feed

  • Question

  • User1711320758 posted

    I have a project that uses the ClaimsPrincipal to get the CurrentUser.Identity.Name.  When I run the same piece of code in Visual Studio 2017 the name field is blank.

    This is not a .NET Core project but just a regular .NET library.   The problem appears only happens in unit test applications and there is no problem when the code executes under IIS for example. 

    Did something change in the .NET System library that visual studio 2017 uses?  I can replicate 100% of the time. If I create a 2015 project the code works perfectly as expected.  In 2017 the code returns empty string.  Again, this is only for Test projects but still needed.

    The object Im referring to is:  ClaimsPrincipal.Current.  And the property is ClaimsPrincipal.Current.Identity.Name.

    I found an article indicating that the ClaimsPrincipal changed for .NET core but I did not think it would would matter for regular .NET libraries.

    Any suggestions to preserve the same outcome in 2017 as 2015 ?

    Thanks, 

    Tuesday, January 23, 2018 9:39 PM

All replies

  • User347430248 posted

    Hi mru22,

    Can you try to share the sample code or sample project?

    We will try to make a test on our side and try to reproduce the issue on our side.

    If it is some kind of bug then we can try to report it.

    Thanks for your understanding.

    Regards

    Deepak

    Thursday, January 25, 2018 9:40 AM
  • User1711320758 posted

    For us its simply open a unit test project in Visual studio 2017 and type the following:

    ClaimsPrincipal.Current.Identity.Name;

    In 2017 the value is an empty string.

    In 2015 the value includes my NTID.

    Thanks,

    Friday, January 26, 2018 6:36 PM