ClaimsPrincipal.Current Visual Studio 2017 different behavior

我怕爱的太早我们不能终老 提交于 2019-12-11 16:00:42

问题


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:


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.



来源:https://stackoverflow.com/questions/45752888/claimsprincipal-current-visual-studio-2017-different-behavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!