Can I access session state from an HTTPModule?

Found this over on the ASP.NET forums: using System; using System.Web; using System.Web.Security; using System.Web.SessionState; using System.Diagnostics; // This code demonstrates how to make session state available in HttpModule, // regardless of requested resource. // author: Tomasz Jastrzebski public class MyHttpModule : IHttpModule { public void Init(HttpApplication application) { application.PostAcquireRequestState += new EventHandler(Application_PostAcquireRequestState); application.PostMapRequestHandler += … Read more

What is the difference between SessionState and ViewState?

Session State contains information that is pertaining to a specific session (by a particular client/browser/machine) with the server. It’s a way to track what the user is doing on the site.. across multiple pages…amid the statelessness of the Web. e.g. the contents of a particular user’s shopping cart is session data. Cookies can be used … Read more

In ASP.NET, when should I use Session.Clear() rather than Session.Abandon()?

Session.Abandon() destroys the session and the Session_OnEnd event is triggered. Session.Clear() just removes all values (content) from the Object. The session with the same key is still alive. So, if you use Session.Abandon(), you lose that specific session and the user will get a new session key. You could use it for example when the … Read more