Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Attributes, session management, weblogs and Google


I just had a faint memory of an e-mail by Clemens Vasters about a small set of .NET attributes for managing ASP.NET sessions. The idea was (now I know) to do something like this:

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++;            
         }


         // omissions...

So there you go: use plain class fields to manage session (also page and application) state, a cool demo of .NET attributes versatility. But I didn't remember how it worked, let alone when it was... So of course I used a Google search ("clemens vasters session attribute") and was immediately taken to this entry in his weblog. Somebody should measure the impact on programmer's productivity of supposedly collateral things like google, weblogs and attributes.

1 Comment

  • How to use the clemen vester's code for session store in a class library??

    scenario is :

    The session that is abruptly ended(not logged out)by a user must be stored and resumed the next time when the same user enters....

    Plz help me with this ...

Comments have been disabled for this content.