Scott Hanselman

ASP.NET, Response.Write and Response.Output.Write - know the difference

January 3, '04 Comments [3] Posted in ASP.NET
Sponsored By

A fellow emailed me just now wanting to know the difference between Response.Write() and Response.Output.Write() in ASP.NET.  Well sir, I'm glad you asked, because it's damned interesting. :)  The short answer is that the latter gives you String.Format-style output and the former doesn't.  The long answer follows.

In ASP.NET the Response object is of type HttpResponse and when you say Response.Write you're really saying (basically) HttpContext.Current.Response.Write and calling one of the many overloaded Write methods of HttpResponse. 

Response.Write then calls .Write() on it's internal TextWriter object:

public void Write(object obj){ this._writer.Write(obj);}

HttpResponse also has a Property called Output that is of type, yes, TextWriter, so:

public TextWriter get_Output(){ return this._writer; }

Which means you can to the Response whatever a TextWriter will let you.  Now, TextWriters support a Write() method ala String.Format, so you can do this:

Response.Output.Write("Scott is {0} at {1:d}", "cool",DateTime.Now);

But internally, of course, this this is happening:

public virtual void Write(string format, params object[] arg)
{
   this.Write(string.Format(format, arg)); 
}

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Part 2: Shadows of future versions of Outlook - the researcher speaks

January 3, '04 Comments [0] Posted in Programming
Sponsored By

The power of the Internet (connecting the planet) combined with the concepts of subcultures (everyone is interested in something) and blogging (your own syndicated column) never cease to amaze.  My posting of some Microsoft UI Research around threaded email discussion was Slashdotted last week.  Lots of good discussion ensued, but today a very cool thing happened.  The actual Microsoft Researcher, Gina Venolia, posted in the comments section.  I confirmed that her post is legit.  More importantly she brings up some very good points that I’d like to share.  I’ve split up her comment into sections for me to comment on, but her full text remains unchanged.

I am the person doing the work being discussed.  I think that there are two things of note in the (maybe not too well written) article.  The first is that you can get rid of the headers-and-message-viewer arrangement of most (all?) email programs.  This is probably a good thing because it can turn a lot of clicking on headers into a continuous view.  It's not exactly rocket science or novel - see the thread visualizations in www.dotnet247.com (e.g. http://www.dotnet247.com/247reference/msgs/34/170488.aspx) or www.lugnet.com (e.g. http://news.lugnet.com/cad/dat/parts/?n=4988&t=i&v=a).

True that the article I posted was an internal “puff” piece meant to let people know what’s going on inside Microsoft Research.  It’s fair to say that the author of the piece is not a researcher in this field, and one can’t take an article like this written for a broad audience as a valid abstract of some fairly complex research.  

Her first point is one I agree with.  The whole master-detail/headers-message paradigm goes against productive viewing of threaded discussion.  While many sites, like those she mentioned, and many apps (SharpReader being the most notable, IMHO) push the envelope for threading while still maintaining the headers-message multi-paned approach, the concept isn’t exactly splitting-atoms-hard.

The second is that the visualization shows both the sequence of messages and the reply tree at the same time. (Emphasis Scott’s)  No doubt about it, you've been able switch between both of these views in email clients for years.  The sequence is good because you can see what new in a thread that you're coming back to; it's also good because people aren't replying to only the parent messsage, but things that they've read in the other branches.  The reply tree is useful for obvious reasons.  With this visualization you can do both AT THE SAME TIME, which is a good thing.

I’ve always preferred applying additional thought around tough UI problems than the cop-out of a “toggle” between views.   Rather than developing an opinion around the article, I took her very valid advice and read one of her published papers online.  This excerpt from her abstract clearly expresses the intent of this research, which is certainly more than “yet another threaded email client” - again, emphasis mine.

“We present a mixed-model visualization that simultaneously presents sequence and reply relationships among the messages of a conversation, making both visible at a glance. We describe the integration of the visualization into a working prototype email client. A usability study indicates that the system meets our usability goals and verifies that the visualization fully conveys both types of relationships within the messages of an email conversation.”

She refers to research by Clark [(1996). Using language. Cambridge University Press.] that
defines utterances in face-to-face conversations as projects, subprojects and digressions, leading to five types of transitions (pair-wise relationships) between utterances: next, push, pop, digress and return.”  Applying these concepts to the question of “What is a conversation” leads them to develop a visualization that expresses these constructs with as peers with full fidelity.  

They acknowledge prior research and plot their accomplishments in a grid to show at a glance support for the Tree Model of a conversation versus the Sequential Model.   Refer to the research document for details about each of these different research projects, such as Loom and ConverSpace.  Note, however, that typical Usenet discussions offer some support for the Tree Model, but it’s clear that most interfaces break down around the display of sequentially ordered messages.  It’s usually an either-or situation (a toggle.)

In the comments section, Gina mentions when many Slashdot users mentioned to me – IBM’s ReMail project.  IBM includes improved support for conversation visualization with something called a “ThreadArc.”  This is also an attempt a  “mixed-mode” visualization to express both Sequence and Reply relationships between messages.  ThreadArcs uses arcs to express a reply-to relationship between messages, and dots to represent each message, with those dots sorted left to right (in English) based on a user-defined sort, usually chronological.  It is their belief that a ThreadArc presents a more stable visualization which allows the user to better see the evolution of a message thread over time.

Gina ends her comment with a reminder to read the research and make your opinions, rather than trign to glean details from an article about the research.  Point well taken.

The combination of these two things is, I believe, what makes this part of Grand Central novel and interesting.  In current email clients and IBM's ReMail, you have to assemble an understanding of what's going on in a thread by looking a message at a time, navigating by clicking on headers, scrolling, etc.  In this view it's all laid out at once, navigable with a scrollbar, shifting the burden from the cognitive to the visual system.  This, I think, is a very good thing.

Instead of basing your opinions on a short article and a screen shot, I suggest reading a little deeper: http://research.microsoft.com/research/pubs/view.aspx?msr_tr_id=MSR-TR-2002-102

Thanks, Gina, for reading my blog and helping spread the word about your research!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Ending the Year with Obscurity: JIT Debugging failed with the following error

January 1, '04 Comments [1] Posted in ASP.NET | Bugs
Sponsored By

Here’s a yummy and odd thing.  I hooked up some global error handling in my big ASP.NET app.  I put it in two places. 

The first place was a handler for the Error event in the base class for all my pages.  I had a call to log4net to log the error and a Redirect that would show the user a friendly explanation of what went wrong.

The second place was the Application Error handler in Global.Asax.cs.  Same drill.  This handler is for errors that happen outside the scope of my base class (like ASHX files, etc).

Remember that the call to Redirect (Transfer in one case) was commented out for development.  It was commented out for months and months.  I uncommented it today.

Suddenly I started seeing this ominous dialog when running Visual Studio.NET.  NOTE: I said RUNNING VS.NET, not running the app.  I get this as soon as the CSProj gets loaded!  Eek!

This stumped me, as this dialog is the kind of thing you see when you’re not the DebuggerUsers Group, yada yada yada.  I googled some, and all the references to this dialog refer to permissions and such, and this was clearly not a permission thing as nothing had changed in that ‘hood.

Since I had log4net (glorious, BTW) hooked up, I setup the FileAppender to log all my copious Debug statements to a file.  I launched VS.NET and loaded the project.  Turned out some of my pages were being flat-out executed either as VS.NET asked for them from IIS or as they were loaded into the Designer (I’ve complained about this designer thing before).  In my Init() of a deep base class a I was checking Request.UserLanguages[0] for the user’s preferred language.  Yeah, I know, I didn’t check to see if [0] was there.  It always has been!  Well, apparently it’s not there when VS.NET calls with HTTP to IIS.

Long story short, a NullReferenceException occurred which was now CAUGHT by my Exception handler and I tried to call Response.Transfer which boogered up VS.NET who decided that Debugging was never going to work.  Preventing that exception stopped this strange VS.NET startup error.

Happy New Year!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Google Dance Syndrome

December 29, '03 Comments [0] Posted in ASP.NET | Bugs
Sponsored By

 Good stuff…just the thing my buddy Adam Cogan is looking for as he dances to the top of the charts!

You’ve used google before, but did you know they keep copies of their index around the world? And when the index is being updated, you can search on the same phrase at different times, and get different results. If you would like to see how that phrase looks across all clusters of their indexes, check out http://www.google-dance.com/
[Wanta .NET ?]

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Merry Christmas: Reunited

December 25, '03 Comments [3] Posted in Africa
Sponsored By

Merry Christmas folks.  After two and a half years apart my sister-in-law's husband, eight-year-old and three-year-old have finally joined us stateside.  Our little house has upped its number of occupants to 6.  They are in America to stay.  One day I'll tell you the story of their trip, but it included a bus breaking down 600 km away from Johannesburg on the way to meet their plane.  He hitchhiked with the two kids and 3 bags all the way to South Africa and made it to the plane in time.  After 26 total hours in a plane and 13 total layover hours (not to mention the 18 hour bus/hitchhiking experience) they are together at last.  It's truly the culmination of years of work on everyone's part.

Merry Christmas!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.