diff --git a/src/Microsoft.Identity.Web/WebAppExtensions/WebAppAuthenticationBuilderExtensions.cs b/src/Microsoft.Identity.Web/WebAppExtensions/WebAppAuthenticationBuilderExtensions.cs index 19c79aeb1..2a9905e74 100644 --- a/src/Microsoft.Identity.Web/WebAppExtensions/WebAppAuthenticationBuilderExtensions.cs +++ b/src/Microsoft.Identity.Web/WebAppExtensions/WebAppAuthenticationBuilderExtensions.cs @@ -136,12 +136,19 @@ public static AuthenticationBuilder AddMicrosoftWebApp( if (!string.IsNullOrWhiteSpace(login)) { context.ProtocolMessage.LoginHint = login; - context.ProtocolMessage.DomainHint = context.Properties.GetParameter( - OpenIdConnectParameterNames.DomainHint); - // delete the login_hint and domainHint from the Properties when we are done otherwise + // delete the login_hint from the Properties when we are done otherwise // it will take up extra space in the cookie. context.Properties.Parameters.Remove(OpenIdConnectParameterNames.LoginHint); + } + + var domainHint = context.Properties.GetParameter(OpenIdConnectParameterNames.DomainHint); + if (!string.IsNullOrWhiteSpace(domainHint)) + { + context.ProtocolMessage.DomainHint = domainHint; + + // delete the domain_hint from the Properties when we are done otherwise + // it will take up extra space in the cookie. context.Properties.Parameters.Remove(OpenIdConnectParameterNames.DomainHint); }