Can't i set Session in a class file?

Posted by uzay95 on Stack Overflow See other posts from Stack Overflow or by uzay95
Published on 2010-04-27T18:36:04Z Indexed on 2010/04/27 18:43 UTC
Read the original article Hit count: 289

Filed under:
|

Why session is null in this even if i set:

public class HelperClass
{
    public AtuhenticatedUser f_IsAuthenticated(bool _bRedirect)
    {
        HttpContext.Current.Session["yk"] = DAO.context.GetById<AtuhenticatedUser>(1);
        if (HttpContext.Current.Session["yk"] == null)
        {
            if (_bRedirect)
            {
                HttpContext.Current.Response.Redirect(ConfigurationManager.AppSettings["loginPage"] + "?msg=You have to login.");
            }

            return null;
        }

        return (AtuhenticatedUser)HttpContext.Current.Session["yk"];
    }
}

alt text

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about session