Archives / 2008 / August
  • Shame and Down to Earth HttpContext.Items Property

    There is a few options to used if you want to stored object on the server-side. Some of the common techniques people used are including Session, Cache, Application. There's a different between each of the techniques.Obviously Items does not gain a lot of attention from developer. Mike Duncan has posted 3 hot uses for HttpContext.Current.Items that might change the way developers look at it. So what it is? What so special about it? Where can I used it? Taken from MSDN site:

    Gets a key/value collection that can be used to organize and share data between an IHttpModule interface and an IHttpHandler interface during an HTTP request.

    Notice the word HTTP request. It can be used to stored object in a single HTTP request to achieve a singleton in ASP.NET (only in single request). Ah ha. Simple idea how we can take advantage of this is by creating a class that can be used to stored key and object in a single HTTP request. This idea can be expand to create a more reusable framework for managing context. Another advantage of this property is that you can add object in all http request pipeline. Meaning you can share data between httpmodules and httphandlers implementation. One example use of HttpContext.Items is to store page setting when visitor request for the page.

       1: public static PageSettings GetPageSetting()
       2: {
       3:     if (HttpContext.Current == null) return null;
       5:     PageSettings currentPage = HttpContext.Current.Items["CurrentPage"] as PageSettings;
       6:     if (currentPage == null)
       7:     {
       8:         currentPage = LoadCurrentPage();
       9:         if (currentPage != null)
      10:             HttpContext.Current.Items["CurrentPage"] = currentPage;
      11:     }
      12:     return currentPage;
      13: }

    There's lack of documentation about HttpContext.Items from Microsoft. Here's are some of the resources I found:

    Until next time.


  • Bridging TFS and SVN


    This is my second attempt to write on a public on what I've found interesting to be shared and I hope it can established a series of posting. From The Pragmatic Programmer's book tip #23: Always Use Source Code Control. For me, using source control is not just for tracking purpose. There's a lot of free source code project hosting available publicly on the Internet. One of the reason I've installed TortoiseSVN on my machine is to let me sync down those open source codes from public hosting such as, or (this require CVS). For you can use TortoiseSVN directly because it was hosted using Subversion server. For, Microsoft's open source project hosting web site, the source code was hosted using Microsoft's proprietary Team Foundation Server (TFS). You can you either use TortoiseSVN or CodePlex Client to access the code repository. I prefer to use TortoiseSVN since I already used it to access the code from other SVN server. This is possible with SvnBridge, a tool that converts the call made by subversion client to the API supported by TFS. The developer's planet is lucky enough to have TFS SDK available, this will allow other tool to talk to TFS. To get it running on your local machine is pretty easy and no harm.  
    It's a mandatory tools to be installed on your machine since a few cool projects hosted there:
    Now lots of source codes to be sync down.