csharp Loop through Session

public static string GetSession()
{
	#if (DEBUG)
	StringBuilder sb = new StringBuilder();

	sb.AppendLine("<table>");
	sb.AppendLine("<tr><td>Key</td><td>Value</td></tr>");

	System.Collections.IEnumerator en = Session.Keys.GetEnumerator();
	en.MoveNext();

	foreach (string key in Session.Keys)
	{
		sb.AppendFormat("<tr><td>{0}</td><td>{1}</td></tr>", key, Session[key]);
	}
	sb.AppendLine("</table>");

	return sb.ToString();
	#else
	return "";
	#endif
}
Loops through Session and returns them as a HTML table. Includes DEBUG to avoid rendering when in production.

Updated: Tuesday 27th September 2011, 22:39pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.