Last active
August 29, 2015 14:02
-
-
Save tekguy/2ea019f3a7f1fae2128f to your computer and use it in GitHub Desktop.
Logging off ACS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult LogOff() | |
{ | |
// Load Identity Configuration | |
FederationConfiguration config = FederatedAuthentication.FederationConfiguration; | |
// Get wtrealm from WsFederationConfiguation Section | |
string wtrealm = config.WsFederationConfiguration.Realm; | |
string wreply; | |
// Construct wreply value from wtrealm (This will be the return URL to your app) | |
wreply = wtrealm; | |
// Read the ACS Ws-Federation endpoint from web.Config | |
// something like "https://<your-namespace>.accesscontrol.windows.net/v2/wsfederation" | |
string wsFederationEndpoint = ConfigurationManager.AppSettings["ida:Issuer"]; | |
SignOutRequestMessage signoutRequestMessage = new SignOutRequestMessage(new Uri(wsFederationEndpoint)); | |
signoutRequestMessage.Parameters.Add("wreply", wreply); | |
signoutRequestMessage.Parameters.Add("wtrealm", wtrealm); | |
FederatedAuthentication.SessionAuthenticationModule.SignOut(); | |
string signoutUrl = signoutRequestMessage.WriteQueryString(); | |
return this.Redirect(signoutUrl); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment