New to this...
asp.net, C# 4.0
I am trying to loop through an object that I have put into a session for debugging display purposes.
I used this...
// set the user into a session either loggedin or current
public static void SetUserInfo(UserInfo User, bool LoggedIn)
{
string uType = _currentUser;
if (LoggedIn){ uType = _loggedInUser;}
if (HttpContext.Current.Session[uType] != null)
HttpContext.Current.Session[uType] = User;
else
HttpContext.Current.Session.Add(uType, User);
}
//return the current UserInfo
public static UserInfo GetCurrentUser(bool LoggedIn)
{
string uType = _currentUser;
if (LoggedIn) { uType = _loggedInUser; }
return HttpContext.Current.Session[uType] as UserInfo;
}
Now this is where I am stuck...
StringBuilder _sb = new StringBuilder();
_sb.Append("<hr>");
_sb.Append("<b>Current Session Count</b>");
_sb.Append("<hr>");
_sb.Append("Session Count: ");
_sb.Append(HttpContext.Current.Session.Count.ToString());
_sb.Append("<hr>");
_sb.Append("Logged In User: ");
UserInfo u = UserInfoManager.GetCurrentUser(true);
_sb.Append("Name: ");
_sb.Append( u.UserName.ToString() );
_sb.Append("<br>");
//need to loop here
_res = _sb.ToString();
I want to display each item...what is a better way?
thanks tons
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.