Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

Please ask your help in the following:
I have a ActionFilterAttribute basically to check if session is timed out. I have the following issues:
(1) Unable to get the current context to save the session variables to a table
(2) Unable to inject signmanager so that I can force a Signout of the current user.
(3) Unable to get if the session is still active or not. Currently I am doing a workaround by means of checking for a session variable is Null or not to check for session timeout.

I have been trying a lot using the filtercontext to derive but am unsuccessful. Any pointers in the correct direction will be very helpful.

I am copying the code for your reference

Regards
Santosh

What I have tried:

public override void OnActionExecuting(ActionExecutingContext filterContext)
{

    var sessionVar = filterContext.HttpContext.Session.GetString("sessionVar");
    if (sessionVar == null)
    {

        string s = filterContext.HttpContext.Request.Scheme;

        string redirectTo = "/";
        filterContext.HttpContext.Response.Redirect(redirectTo);
    }
    base.OnActionExecuting(filterContext);
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900