Social Networking Sites and Session Objects

"I had a dream I was stuck in an elevator with Michael Bolton, Kenny G. and Yanni,
and I had a gun - with only one bullet."
-- Alan Rock (Jazz DJ)

One good answer to Alan's quote above would be to get them all to line up, one right behind the other.. but, I digress!

I have had a passing interest in the social networking buzz over the last couple of years, and the ones with API's are of course most interesting to me as a developer.

Digg is useful, and it has an API, but it really has a more narrow focus based on community ranking of posted "news" (e.g., articles, blog posts and what have you), rather than more of a concept of "communities" comprised of members who share common interests / traits.

One that is really starting to stand out is FaceBook, which has a clean, uncluttered look and actually has features that could be considered useful, unlike stuff like MySpace which (to me) is just a cluttered mess of spam and "me too" ism.

Of course the question that comes into play is "How long will it last" -- it's one thing to have 30 million users sign up like rubberneckers at a car crash, but will the usage statistics persist. Probably only Steve Ballmer knows, as rumor has it he's been trying to acquire the sucker for a ridiculous sum (in the $B's).

Another reason why I'm starting to get interested in facebook is that it can import your email contacts and uses these to determine potential "friends" - so that when you join you may be pleasantly surprised that a number of your contacts from LinkedIn, hotmail, yahoo or other mail are already members.

In fact, I saw this morning that Rob Howard had just added me as a friend (that's a compliment, Rob!). But the real interest, I think, is the FaceBook API. You can go to codeplex.com and search on "Facebook" and you'll see that there are no less than four projects that deal with .NET-ized versions of the API.

Nikhil Kothari has some work that he's done on this and also has a lot of good pointers to resources that you can find here. Time permitting, I'll be doing some work on this to figure out sensible ways that I can integrate the Facebook API into one or more of my current "playground" sites. See you on facebook!

Session Object Fun

I keep seeing various posts regarding misunderstandings of how Session works in ASP.NET. It's reference - if you modify an object that's in Session, the SESSION OBJECT is modifed. Here's some reallyreallydumb code that brings it home quickly:


protected void Page_Load(object sender, EventArgs e)
{
// Let's Drop a Gridview on the page, and create a data source...
DataTable dt = new DataTable();
dt.Columns.Add("Test");
// let's add a row
DataRow row = dt.NewRow();
// give the column a value
row["Test"] = "First";
dt.Rows.Add(row);
// store it in Session
Session["dt"]=dt;
// now let's modify the ORIGINAL OBJECT
dt.Rows[0]["Test"] = "Second";
// now let's bind our grid from the SESSION object
GridView1.DataSource = (DataTable) Session["dt"];
GridView1.DataBind();
// it says "Second" -- in other words, our SESSION OBJECT is MODIFIED,even though we never worked on it directly.
This behavior can cause a lot of slip-ups for developers who are not familiar with it.
}

Comments

  1. um, I'm just a Computer Science fresh grad. I find a article http://www.eggheadcafe.com/articles/20050821.asp by you.
    That's very useful for me. Thank you.
    but I may suggest to add a "ostream.Close()" after adding the zip entry. as you should know, the reference hold the file for certain time.

    ReplyDelete
  2. Only when using the InProc Session state provider will you getthe behavior you are talking about. For the SQL Session State provider or the Out-of-Proc provider, you're not talking about the same objects... it's a marsahlled copy.

    ReplyDelete
  3. Good Point IDisposable!

    ReplyDelete

Post a Comment

Popular posts from this blog

ASP.NET: Loss of Session / Cookies with Frames

FIREFOX / IE Word-Wrap, Word-Break, TABLES FIX