diff --git a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationHandler.cs index 4a43b58be4..63c524afa6 100644 --- a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationHandler.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Security.Cookies protected override AuthenticationTicket AuthenticateCore() { - return AuthenticateCoreAsync().Result; + return AuthenticateCoreAsync().GetAwaiter().GetResult(); } protected override async Task AuthenticateCoreAsync() @@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Security.Cookies protected override void ApplyResponseGrant() { - ApplyResponseGrantAsync().Wait(); + ApplyResponseGrantAsync().GetAwaiter().GetResult(); } protected override async Task ApplyResponseGrantAsync() diff --git a/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationHandler.cs b/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationHandler.cs index eae1463638..5a4ffebbd2 100644 --- a/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationHandler.cs @@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Security.OAuth protected override AuthenticationTicket AuthenticateCore() { - return AuthenticateCoreAsync().Result; + return AuthenticateCoreAsync().GetAwaiter().GetResult(); } protected override async Task AuthenticateCoreAsync() diff --git a/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationHandler.cs b/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationHandler.cs index b49db1f715..406085b670 100644 --- a/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationHandler.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Security.OAuth protected override AuthenticationTicket AuthenticateCore() { - return AuthenticateCoreAsync().Result; + return AuthenticateCoreAsync().GetAwaiter().GetResult(); } protected override async Task AuthenticateCoreAsync() diff --git a/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationHandler.cs b/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationHandler.cs index 7eeac5702d..7717642a1d 100644 --- a/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationHandler.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNet.Security.Twitter protected override AuthenticationTicket AuthenticateCore() { - return AuthenticateCoreAsync().Result; + return AuthenticateCoreAsync().GetAwaiter().GetResult(); } protected override async Task AuthenticateCoreAsync() @@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Security.Twitter } protected override void ApplyResponseChallenge() { - ApplyResponseChallengeAsync().Wait(); + ApplyResponseChallengeAsync().GetAwaiter().GetResult(); } protected override async Task ApplyResponseChallengeAsync() diff --git a/src/Microsoft.AspNet.Security/DefaultAuthorizationService.cs b/src/Microsoft.AspNet.Security/DefaultAuthorizationService.cs index aaa1dbc103..0b05a6d3dd 100644 --- a/src/Microsoft.AspNet.Security/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNet.Security/DefaultAuthorizationService.cs @@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Security public bool Authorize(IEnumerable claims, ClaimsPrincipal user, object resource) { - return AuthorizeAsync(claims, user, resource).Result; + return AuthorizeAsync(claims, user, resource).GetAwaiter().GetResult(); } private bool ClaimsMatch([NotNull] IEnumerable x, [NotNull] IEnumerable y) diff --git a/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationHandler.cs b/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationHandler.cs index f7e5adc342..a5fd9876cb 100644 --- a/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationHandler.cs @@ -183,7 +183,7 @@ namespace Microsoft.AspNet.Security.Infrastructure () => { return Task.FromResult(AuthenticateCore()); - }).Result; + }).GetAwaiter().GetResult(); } protected abstract AuthenticationTicket AuthenticateCore(); @@ -225,7 +225,7 @@ namespace Microsoft.AspNet.Security.Infrastructure { ApplyResponseCore(); return Task.FromResult(0); - }).Wait(); // Block if the async version is in progress. + }).GetAwaiter().GetResult(); // Block if the async version is in progress. } protected virtual void ApplyResponseCore() diff --git a/test/Microsoft.AspNet.Security.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNet.Security.Test/DefaultAuthorizationServiceTests.cs index fd3a668a25..a5a003b801 100644 --- a/test/Microsoft.AspNet.Security.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Security.Test/DefaultAuthorizationServiceTests.cs @@ -242,7 +242,7 @@ namespace Microsoft.AspNet.Security.Test // Act // Assert - Exception ex = Assert.Throws(() => authorizationService.Authorize(Enumerable.Empty(), null)); + Exception ex = Assert.Throws(() => authorizationService.Authorize(Enumerable.Empty(), null)); } [Fact]