You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I was working on Chapter 03 Challenge, I got an error saying "The trust relationship between this workstation and the primary domain failed" in _Layout.cshtml line 32.
I use Windows 10, Visual Studio 2017 Community Edition and IIS Express when got this error.
From this solution, I found that User.IsInRole seems to throw an exception when Windows.Identity.IsAuthenticated is false. So I use that solution, adding an authentication checking before User.IsInRole.
Below is the solution.
When I was working on Chapter 03 Challenge, I got an error saying "The trust relationship between this workstation and the primary domain failed" in _Layout.cshtml line 32.
@if (User.IsInRole(HPlusSports.Models.UserRoles.Admin))
I use Windows 10, Visual Studio 2017 Community Edition and IIS Express when got this error.
From this solution, I found that User.IsInRole seems to throw an exception when Windows.Identity.IsAuthenticated is false. So I use that solution, adding an authentication checking before User.IsInRole.
Below is the solution.
@if (User.Identity.IsAuthenticated && User.IsInRole(HPlusSports.Models.UserRoles.Admin))
The text was updated successfully, but these errors were encountered: