SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a custom STS for SP.The site is SAML token enabled with SSO implmentation. The logout is not working properly.How do i implement custom Signout .do i need to clear the SP session or clear cookies?

share|improve this question
Doesnot work in Mozilla . . – Nikhil Jangle Jan 3 '13 at 16:22
The FedAuth Cookies doesnot get cleared in any browsers except IE.You somehow need to clear "FedAuth" cookie from sharepoint and it worked for me . – Nikhil Jangle Jan 19 '13 at 13:26
up vote 2 down vote accepted

I've just tackled this exact task this morning. You'll need your Custom STS to keep track of the sites that are logged in, and in the wsignout1.0 handler, you'll need to go through the list and sign them out.

Full description of this method, a helper class to keep track of the RPs logged into, and code to add to your wsignout handler are all here:

I made one modification to the helper class though, I added a CleanUp method to remove the cookie that keeps track of the RPs once you're signed out:

public static void CleanUp()
    HttpCookie siteCookie = HttpContext.Current.Request.Cookies[SITECOOKIENAME];

    if (siteCookie != null)
        HttpContext.Current.Response.Cookies[SITECOOKIENAME].Expires = DateTime.Now.AddDays(-1);

And then, at the end if your signout handler, just call it. Here's my signout handler block:

        else if ( action == WSFederationConstants.Actions.SignOut )
            // Process signout request.
            SignOutRequestMessage requestMessage = (SignOutRequestMessage)WSFederationMessage.CreateFromUri( Request.Url );
            FederatedPassiveSecurityTokenServiceOperations.ProcessSignOutRequest( requestMessage, User, requestMessage.Reply, Response );

            string[] signedInUrls = SingleSignOnManager.SignOut();
            lblSignoutText.Visible = true;
            foreach (string url in signedInUrls)
                    new LiteralControl(string.Format(
                        "<p><a href='{0}'>{0}</a>&nbsp;<img src='{0}?wa=wsignoutcleanup1.0' " +
                        "title='Signout request: {0}?wa=wsignoutcleanup1.0'/></p>", url)));


Works like a charm. Remember to create an asp:Label called lblSignoutText and a div called SignOutLinks on your Default.aspx

The only thing you'll have to figure out yourself, is that each SharePoint site's logout link will need to be hidden, and you'll have to create your own signout link which points to:


(I was actually Googling for a clever way of doing this when I came across this question. Hope my answer helps!)

share|improve this answer
Thanks for reply.Let me explain you the whole scenario.i am using SSO for external partners.So i have a logoff link for each external partner.Right now when i click logoff i am sending the user to a Sharepoint XYZ page.but when i click back button in IE i land up in the site without credentials.So onclick of logoff ,i need to send it to the STS and use the above code to logout successfully ? – Nikhil Jangle Dec 27 '12 at 16:52
exactly, you need the external partner pages to go to your sts site with querystring params wa=wsignout1.0 and itll run the above code. you'll also need to modify the code that creates the claims in your sts to keep track of the sites already logged into. – James Love Dec 27 '12 at 20:29
i tried the above code and worked fine,Thanks.Right now i have simulated identity provider.So when i logoff i get to the page logout page and when i try to go inside the site it goes through the STS again for logging in site.So its logging out correct ? Also i tried to replace the code new LiteralControl(string.Format( "<p><a href='{0}'>{0}</a>&nbsp;<img src='{0}?wa=wsignoutcleanup1.0' " + "title='Signout request: {0}? and tried to redirect to my custom page anonymous page in sharepoint.but after doing this the logout isnt working. – Nikhil Jangle Dec 29 '12 at 7:05
Also after logout , if i click back button in IE i am able to get inside sp application – Nikhil Jangle Dec 29 '12 at 7:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.