ClaimsPrincipal.Current Visual Studio 2017 differe

2019-09-18 19:43发布

I am running a VS2012 MVC 5 project on 2017 . All seems to work fine except that ClaimsPrincipal.Current does not return the same thing!!

The exact same code works perfectly on VS2012 , Development and Production server. Although when running the project from VS2017 ClaimsPrincipal.Current behaves differently.

Doing some research i found this article http://davidpine.net/blog/principal-architecture-changes/

Stating that in .NET Core ClaimsPrincipal.Current should behave differently .

Thing is that in my case i am running the exact same .NET version in both IDE's (4.0.30319.42000) and verified that with Environment.Version.

Also hitting F12 on ClaimsPrincipal.Current navigates to the exact same mscorlib.dll file.

Any help would be appreciated.

1条回答
放我归山
2楼-- · 2019-09-18 20:36

Found what was causing this !

WebMatrix.Data.dll
WebMatrix.WebData.dll

When these files are present in the bin folder, they cause this behavior . Additionally they overwrite RazorVersion and cause the Development server to throw not matching assembly reference exceptions.

In my project i had a reference to WebMatrix.WebData Version 2.0.0.0

Visual Studio 2012 was ignoring that reference for some reason and it wasn't publishing WebMatrix.dll to the bin folder so everything was working fine.

Visual Studio 2017 was publishing those dlls into the bin folder and that caused this conflict which probably was overriding the built in Simple Membership Provider implementation.

Removing the reference to WebMatrix fixed the issue.

查看更多
登录 后发表回答