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))