tags:

views:

71

answers:

3

Hi everybody! In my ongoing web project i encountered a problem regarding redirection. The scenario is this:

a) user logs on.

b) the count of records in a specific table determines if the user will be redirected to a specific controller/action

c) user arrives in that particular controller/action and does something here

d) (after having done what must be done) the user must be forced to log out (can this be done somehow automatically?)

I think i already implemented this scenario until c) using ActionFilterAttribute (by decorating all the controllers with that particular class).

But how do i force the user to logout?

Thanks in advance

A: 

It really depends on what "logging" out means in your application. It could be as simple as Session.Abandon in your action before you redirect anywhere.

Langdon
I understand what you are trying to say! So my problem now is: how do i save info for that particular state, so that in the action i retrieve that info? Using session, global variable,...??
savvas sopiadis
A: 

FormsAuthentication.SignOut removes the current forms authentication ticket from the browser. The user will then be required to authenticate themselves before accessing restricted resources.

pmarflee
A: 

Assuming you are using FormsAuthentication, I have a Logout method looking something like this:

    public static string Logout(HttpContext context, string defUrl)
    {
        FormsAuthentication.SignOut();
        var vir = context.Request.ApplicationPath;

        return String.IsNullOrEmpty(vir)
                   ? defUrl
                   : VirtualPathUtility.Combine(vir, defUrl);
    }

The FormsAuthentication.SignOut() is the key part....

Sailing Judo