private static string GetRedirectUri(Saml2Binding binding, Saml2AuthenticationOptions options) { var relayState = binding.GetRelayStateQuery(); if (relayState.ContainsKey(_relayStateRedirectUri)) { var redirectUri = relayState[_relayStateRedirectUri]; return(redirectUri); } if (relayState.ContainsKey(_relayStateReturnUrl)) { var returnUrl = relayState[_relayStateReturnUrl]; var redirectUri = options.ExternalLoginCallbackPath.Add(new QueryString(_relayStateReturnUrl, returnUrl)); return(redirectUri); } return(options.ExternalLoginCallbackPath.Value); }