I am using a global filter in order to determine if a user is allowed to access a certain page/controller. I haven't been able to get a lot of tread of this as I'm not able to do a simple session variable creation. Here is my simplified code:
public class MyActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext context)
{
context.HttpContext.Session.Add("asdfasdf", 1234);
//Check if user is authorized in db
//...
base.OnActionExecuted(context);
}
}
Error:
System.Web.HttpException: Failed to login to session state SQL server for user '<USERNAME>'.
If I comment out Session.Add the application works fine. It's strange because the error given is completely unrelated (I think). How do I get my session variable to work in this case? Better question, is this the correct way to go about user authentication?