Scott Hanselman

Zen Judaism

July 09, 2003 Comment on this post [0] Posted in Musings
Sponsored By

Let your mind be as a floating cloud. Let your stillness be as the wooded glen. And sit up straight. You'll never meet the Buddha with posture like that.

There is no escaping karma. In a previous life, you never called, you never wrote, you never visited. And whose fault was that?

The Tao has no expectations. The Tao demands nothing of others. The Tao does not speak. The Tao does not blame. The Tao does not take sides. The Tao is not Jewish.

Drink tea and nourish life. With the first sip, joy. With the second, satisfaction. With the third, Danish.

The Buddha taught that one should practice loving kindness to all sentient beings. Still, would it kill you to find a nice sentient being who happens to be Jewish?

Zen is not easy. It takes effort to attain nothingness. And then what do you have? Bupkes.

From Zen Judaism:  For You a Little Enlightenment by David M. Bader (Harmony Books) © 2002

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Thanks to the Seattle .NET Developer's Association...

July 09, 2003 Comment on this post [2] Posted in Web Services | ViewState | Bugs | Tools
Sponsored By

Thanks to everyone at the Seattle .NET Developers Association.  I haven't done a lot of User's Group lately, but I had a blast at this one. 

  • Blunck's ieHTTPHeaders for seeing HTTP Headers within an IE Explorer Bar
  • A version of Zoomin, the screen magnifier, is included with Visual Studio 6.0, but there is a freeware version from Brian Friesen.  Both are great, and I actually prefer the flexiblity of Brian's.
  • The .NET IL Disassembler is called ILDASM.EXE and if you have the .NET SDK, this is installed on your system already in the Framework's BIN directory.  It's your best friend.
  • Lutz Roeder is a .NET Legend because of Documentor, Reflector, and Resourer.
  • Fritz Onion's ViewStateDecoder has gotten me out of a few jams.

    A much more complete list of tools is at my list of Web Services tools. One day I'll make a list of all the things in my UTILS folder and blog it.

  • 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 bluesky subscribe
    About   Newsletter
    Hosting By
    Hosted on Linux using .NET in an Azure App Service

    Dinner at the Crossroad Mall on 7/7?

    July 03, 2003 Comment on this post [2] Posted in Web Services | Diabetes
    Sponsored By

    Hey, I'm going to be up in Seattle for the .NET Users Group on the MSFT Campus on Monday, July 7th.  Anyone want to meet at the Crossroads around 4:45pm-5pm?   It's a good excuse to leave work early (research!)...help me carbo load (not really advised for diabetics) before the talk.  Leave me comments here or email me (link at the bottom).

    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 bluesky subscribe
    About   Newsletter
    Hosting By
    Hosted on Linux using .NET in an Azure App Service

    So many mistakes for me to make, so little time...capturing StandardError and StandardOutput

    July 02, 2003 Comment on this post [1] Posted in Web Services | Bugs
    Sponsored By

    This struck me as particularly interesting, because it's one of those "doh!" things that is simultaneously completely obvious after the fact but not obvious on a cursory glance if you're not paying attention.

    If, in C#/.NET, you wish to spawn a process of CMD.EXE /C SomeBatchFileOrSomeProgram.exe, and you wish to capture both the StandardOutput and the StandardError, well, you need to think.

    If you do something like this:

    Process p = new Process();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.FileName = "test.exe";
    p.Start();
    string output = p.StandardError.ReadToEnd();
    p.WaitForExit();

    You'll only get StandardError.  But of course, if you try to ReadToEnd both streams (here's where it's obvious) the first one will of course block if standard error output occurs, since you can't read from standard error until you're done with standard output, etc etc, blah blah, well you get it. 

    string output = p.StandardOutput.ReadToEnd();
    string error = p.StandardError.ReadToEnd();
    p.WaitForExit();  

    There are lots of code samples around that contain this bug.  Of course, the bug won't happen if your spawned console process doesn't mix standard error and standard output.  But, when you spawn a batch file, certainly it will spawn other processes and who knows. 

    This fellow at CodeProject has the right idea, although his sample wasn't created to solve this problem, but rather another.

    Process Proc = Process.Start(Info);
       
    m_StdOutReader = new RedirOutReader(Proc, Printer, Proc.StandardOutput);
    m_StdOutReader.Start();
       
    m_StdErrReader = new RedirOutReader(Proc, Printer, Proc.StandardError);

    m_StdErrReader.Start();  

    He spawns two threads, one to handle standard error and one to handle standard output, which is the alluded-to-and-recommended-but-no-one-wrote-the-sample-cause-it-would-have-been-too-hard solution to this problem. 

    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 bluesky subscribe
    About   Newsletter
    Hosting By
    Hosted on Linux using .NET in an Azure App Service

    The Content-Disposition Saga: Controlling the suggested file name in the Browser's Save As Dialog

    July 01, 2003 Comment on this post [0] Posted in ASP.NET | Web Services
    Sponsored By

    Sometimes when I'm dynamically generating a graphic on the server side, perhaps a chart or graph, or I'm retrieving a check image via Web Services, the user wants to save the time, and I want to control the file name that is suggested in the File|Save As Dialog.  Most often the browser will just recommend the page's file name (the one that was part of the HTTP GET request).  So, how do you control the suggested Save As filename?

    UPDATE: Here's how you do it in IE8.

    Well, you do and you don't.  There's a HTTP Header called Content-Disposition (case senstitive) that is NOT part of the HTTP standard, but rather it's own Request for Comments, RFC 1806.

    HTTP Headers are name values pairs, so they are easily added with the Response object in ASP or ASP.NET You use it like this (the HTTP Headers):

    HTTP/1.1 200 OK
    <snip>
    Content-Disposition: filename=checkimage.jpg
    Content-Length: 76127
    Content-Type: image/JPEG

    Or, if you want to immediately prompt the user with a File Download Box: 

    HTTP/1.1 200 OK
    <snip>
    Content-Disposition: attachment; filename=checkimage.jpg
    Content-Length: 76127
    Content-Type: image/JPEG

    However, Internet Explorer has never really got it right.

    Here's a list of gotchas, starting with my own:

    • On IE 6.0, things mostly work, but if you ALSO setup Cache-Control: no-cache, your suggested filename (and type!) will be IGNORED.  A bummer if you have to choose between security and convienence.  Of course, security wins.
    • On IE 4, the attachment option is flaky, see Q182315
    • On IE 5.5, the attachment option is REALLY flaky, see Q267991 and Q279667 and Q281119
    • On IE 5.0, the filename suggested can mangle your filenames, see Q262042 
    • On nearly all versions of IE, including 6.0, sometimes the browser will use the filename in the address bar instead of the Content-Disposition Header, and with IE5.5SP2 you're expected to change the UseCDFileName registry key, see Q303750.  This was fixed with IE6.0SP1.

    Also, there are some security issues around Content-Disposition, like suggesting evil names of files to make a careless user overwrite /etc/passwd, etc, that were included in the updated RFC 2183

    For classic ASP folks, here are some good code samples around Content-Disposition.

    It's a shame that this can't just work as the spec was written, and it's taken 2+ versions of IE to still get it wrong.

    Note: Remember, if you want to sniff your own HTTP Headers, do it with class and use Jonas Blunck's iehttpheaders.

    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 bluesky subscribe
    About   Newsletter
    Hosting By
    Hosted on Linux using .NET in an Azure App Service

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