How to configure SessionStateAttribute as a global filter in MVC3? In my Global.asax, I have this in the RegisterGlobalFilters method.
filters.Add(new SessionStateAttribute(SessionStateBehavior.Disabled));
And in my home controller I have this.
public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; Session["Blend"] = "Will it blend?"; return View(); } public ActionResult About() { return View(); } }
But for some reason, it still allows me to use the session. However, if I decorate the HomeController class with an attribute myself, I get an error in a line using Session, where the object reference is null, what do I assume if the session is never created?
I begin to doubt that something is wrong with my project. I get small issues like this with standard behavior that should work.
Has anyone had problems with such things?
session attributes asp.net-mvc-3 session-state
Nick albrecht
source share