Preserving hyperlink style settings by session

I was working on an ASP.NET site that wasn’t Community Server yesterday (yeah, wild eh?), and was asked to change the colors of a potentially lengthy list of document links so that users could click on a link, view a document, then return to the list and readily determine which document links they had previously viewed.

Easy, A:Visited, but here was the catch.  It could only be for that session.  The list links had to appear virginal on the next visit.

Okay, how about turning off Response Cache.


That didn’t work on my client’s server.  I need to check into that when I can.  It worked on my office network, but not where we needed it to work.

Then I went into hack mode and thought “unique links…unique session.”  The A:Visited style settings are applied to unique hyperlink addresses.  Add a SessionID to the url!


        <span class=”doclink”><a href='<%#  DataBinder.Eval(Container.DataItem,”fileurl”) +
            “?s=” + HttpContext.Current.Session.SessionID %>’
        <%#  DataBinder.Eval(Container.DataItem,”docname”)%>

My client told me people stopped by his office afterward saying “thank you, thank you, thank you!” for the functionality added by that simple hack. 

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.