Enable loopback
Run in CMD-Shell:
CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe
This happens because Edge runs as a modern Win-App. The network isolation is set – because of security reasons – by default.
Run in CMD-Shell:
CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe
This happens because Edge runs as a modern Win-App. The network isolation is set – because of security reasons – by default.
@using System.DirectoryServices.AccountManagement @helper UserFullName() { using (var context = new PrincipalContext(ContextType.Domain)) { var principal = UserPrincipal.FindByIdentity(context, User.Identity.Name); if (principal != null) { var fullName = string.Format("{0} {1}", principal.GivenName, principal.Surname); @fullName } } }
ILSpy shows for GetUserId():
Public static string GetUserId(this IIdentity identity)
{
if (identity == null)
{
throw new ArgumentNullException(„identity“);
}
ClaimsIdentity claimsIdentity = identity as ClaimsIdentity;
if (claimsIdentity != null)
{
return claimsIdentity.FindFirstValue(http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier);
}
return null;
}
So you need to mock the Extension Method „GetUserId()“ a claim based User-Moq-Object:
var identity = new GenericIdentity(„dominik.ernst@pentasys.de“);
identity.AddClaim(new Claim(„http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier“, „1“));
var principal = new GenericPrincipal(identity, new[] { „user“ });
context.Setup(s => s.User).Returns(principal);
var controller = new YOURController();
controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);