Just a quick question:
How come i can't access Session[key]
on my ActionFilterAttribute class?
(VS always change it to sessionChecker if i press [ )
How am i supposed to get and check the session value? I need to retrieve the ID
that is stored in the session and use it to compare for something.
Here is my code:
Login(post):
[HttpPost]
[ActionName("login")]
public ActionResult login_post(string uname, string pword)
{
using (EmployeeContext emp = new EmployeeContext())
{
//h student log = new student();
int success = emp.login.Where(x => x.username == uname && x.password == pword).Count();
if (success == 1)
{
int id = (from logs in emp.login
join rol in emp.roles on logs.role equals rol.id
where logs.username == uname
select logs.id).First();
FormsAuthentication.SetAuthCookie(uname, false);
Session["Login"] = id;
return RedirectToAction("Details", "Enrollment", new { id = id });
}
return View();
}
}
ActionFilterAttribute class
public class CustomChecker: ActionFilterAttribute
{
public string test { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
int t_id;
t_id = //sessionChecker keeps on appearing whenever i try typing "Session". I get red line from it. How do i access the session?