0

I have a several methods in controller:

public ActionResult Issue()
{
    var message = WSFederationMessage.CreateFromUri(HttpContext.Request.Url);

    // sign in 
    var signinMessage = message as SignInRequestMessage;
    if (signinMessage != null)
    {
        return ProcessWSFederationSignIn(signinMessage, ClaimsPrincipal.Current);
    }

    // sign out
    var signoutMessage = message as SignOutRequestMessage;
    if (signoutMessage != null)
    {
        return ProcessWSFederationSignOut(signoutMessage);
    }

    return View("Error");
}

And the most valuable for me in this question:

private ActionResult ProcessWSFederationSignOut(SignOutRequestMessage message)
{
    FederatedAuthentication.SessionAuthenticationModule.SignOut();

    var mgr = new SignInSessionsManager(HttpContext, _cookieName);

    // check for return url
    if (!string.IsNullOrWhiteSpace(message.Reply) && mgr.ContainsUrl(message.Reply))
    {
        ViewBag.ReturnUrl = message.Reply;
    }

    return View("Signout");
}

All works fine, but, there are interesting moment. This thing works in both cases, if I ended session by myself, or session simply expired. Its fine but actually, I need to tell the difference between those cases, write in ViewBag something like "You are singed out" or "Session expired" depends on result and show it oy the View.

Is there are some kind of way to detect session expired situations or should it be something different?

P.S Sorry for my bad English.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
Olegs Jasjko
  • 2,128
  • 6
  • 27
  • 47
  • It's unfortunate that Thinktecture chose to use the word "Session" in their library, since it has absolutely nothing to do with SessionState. – Erik Funkenbusch Nov 06 '14 at 08:53
  • Well, this didn't change the problem. I'm still need to somehow tell the difference. – Olegs Jasjko Nov 06 '14 at 09:02
  • I was making it clear that this question is not about SessionState, as you have already had one misunderstanding. I don't know the answer, but i'm just trying to make sure you don't get 20 people giving you SessionState answers. – Erik Funkenbusch Nov 06 '14 at 09:05
  • Yep. Well, i guess it quite obvious that the question is not about the SessionState just by looking on code sample, but, yes, now its more clean. – Olegs Jasjko Nov 06 '14 at 09:09

1 Answers1

-1

Since you changed the topic I will update my answer. I haven't used WSFederatinSession but maybe you could store the inf about how session ended (in a cookie for example) and during the next request (in a global asax for example) read this inf and do what you want to do.

free4ride
  • 1,613
  • 1
  • 18
  • 21