Attribute-driven ASP.NET Session Management: The ultimate in style and beauty.
A couple of people seemed to like my attribute driven session management bits, so here's the completed solution for all of your session management desires when writing ASP.NET Web Forms. Cross-roundtrip, cross-page, cross-session, cross-site-visit, cross-page-visit. The XML code comments are the docs, take it, use it, improve it, keep me out of trouble, give credit and otherwise: write less code.
Attributes rock! Teaser:
public class MyPage : StateManagingPage { [PersistentPageState] public int pageVisitsEver; [PersistentPageState("Visits")] public int siteVisitsEver; [SessionPageState] public int pageVisitsThisSession; [SessionPageState("Visits")] public int siteVisitsThisSession; [TransientPageState] public int roundtripsThisPage; // omissions... private void Page_Load(object sender, System.EventArgs e) { pageVisitsEver++; siteVisitsEver++; pageVisitsThisSession++; siteVisitsThisSession++; roundtripsThisPage++; }
11:38:11 PM
|
|