Subscribe: - Scott Hanselman's Weblog
Added By: Feedage Forager Feedage Grade B rated
Language: English
add  appdomain  cassini  debug  don  net  new  page  req  string  stuff  system net  system web  system  test  visual studio  web 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: - Scott Hanselman's Weblog - Scott Hanselman's Weblog

Scott Hanselman's Thoughts on .NET, WebServices, and Life

Last Build Date: Sun, 05 Dec 2004 20:22:20 GMT

Copyright: Scott Hanselman

ATTENTION: RSS Subscribers to using my Radio RSS FEED

Sun, 05 Dec 2004 20:22:20 GMT

If you are receiving this post, you may be subscribed to my Radio UserLand RSS Feed (that I've been silently updating for over a year.)

It's time to stop using that feed as I'm going to stop updating it. Please use this URL for your RSS Feed:


Scott Hanselman


Precompile.axd in ASP.NET 1.1 with System.Web.Handlers.BatchHandler: A harbinger of ASP.NET 2.0 left vestigially in 1.1?

Sun, 05 Dec 2004 01:08:50 GMT

I'm surprised I'm just now noticing this. Jon Galloway hooked up the apparently unused System.Web.Handler.BatchHandler to an httpHandler and was able to precompile all his .ASPX pages. This could be useful during deployment to catch any goofs in ASPX code. Certainly not something you want on in production lest you be DoS'ed with compilation, but a helpful thing regardless.

To set this up at the machine level, add the following line to the section of %windir%\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config:

To set this up at the application level, add the you'll need to create an httpHandlers section like so: [JonGalloway]



Now playing: Stevie Wonder - As


Target: Referral Spam in dasBlog

Sat, 04 Dec 2004 07:37:24 GMT

I've pretty much solved the comment-Spam problem (only one person has voiced their distaste so far) but a recently perusal of my logs and older posts indicated a ridiculous amount of referral spam. 

This is when someone hits a post on your site and has changed/hacked the HTTP Referrer Header to indicate where they came from. If your blog adds this referrer to the page, as most to, you've just linked to Hot Gay Sex (not that there's anything wrong with Hot Sex between consenting adults : ) ) or whatever by their actions.

The story goes when Google comes around, they see that you've linked to them, and they get Google Juice via the Page Rank System.

Not only is this potentially offensive to my readers, it also obscures the posts and comments when they are filled with referrals.

Potential Solutions:

  • Stop printing out referrals on my pages.
    • Personally, I like to see them, and I think they provide value to the reader so they can see other places with information of interest. It also promotes cross-linking between my peer blogs.
  • Modify dasBlog to NOT add icky referrals.
    • This would be idea. However, it will likely be in version 1.7 in some way, either via James Snape's whitelist solution (I think a whitelist removes the point of referrals, and I'll greatly prefer a keyword-based black list) or some other technique.
    • I've avoided running a "private build" of dasBlog so far (as evidenced by my care in creating the CAPTCHA solution without recompiling) and I'd to continue as such
  • Clean the .xml files occasionally with a process
    • This is quick, easy, can be automated, and will work in the short term for me as I await dasBlog 1.7.

So, here was an opportunity to use the only dev stuff I have on my home machine, Visual Studio C# 2005 Express

Here's what I did. Use at your own risk, back up your /content directory, and know that this will only have to run on your "*.dayextra.xml" files from dasBlog. No error handling, no warrenty, but it worked for me. Enjoy.

Usage: TrackingFilter "c:\yourdasblogcontentdirectory"

File Attachment: (9 KB) (for VS.NET 2005, I don't know if it works in 2003)

WARNING: The words I put in the .config file are ; delimited and are unquestionably offensive. Not only do they include most of George Carlin's words but they also include "bloglines" and "artima" because they don't provide a value in my referral list.


GUI Front End to Chris Sells' XmlPreCompiler - For Debugging XmlSerialization Errors

Fri, 03 Dec 2004 22:56:32 GMT

I spend a lot of time with the XmlSerializer (I personally dig it immensely, and I think too many people complain about it, but anyway) and while I put up an article on how to debug directly into the generated assemblies, I noticed that Mathew Nolton has a GUI Front-End to Chris's XmlSerializerPreCompiler.

The tool will check to see if a type can be serialized by the XmlSerializer and shows any compiler errors that happen behind the scenes. +1 for Useful, thanks Chris and Mathew.


HTTP POSTs and HTTP GETs with WebClient and C# and Faking a PostBack

Fri, 03 Dec 2004 07:37:17 GMT

A fellow emailed me wanting to screen scrape, er, ah, harvest a page that only displays the data he wants with a postback. Remember what an HTTP GET looks like under the covers: GET /whatever/page.aspx?param1=value¶m2=value Note that the GET includes no HTTP Body. That's important. With a POST the 'DATA' moves from the QueryString into the HTTP Body, but you can still have stuff in the QueryString. POST /whatever/page.aspx?optionalotherparam1=value Content-Type: application/x-www-form-urlencoded Content-Length: 25 param1=value¶m2=value Note the Content-Type header and the Content-Length, those are important. A POST is just the verb for when you have an HTTP document. A GET implies you got nothing. So, in C#, here's a GET: public static string HttpGet(string URI) {    System.Net.WebRequest req = System.Net.WebRequest.Create(URI);    req.Proxy = new System.Net.WebProxy(ProxyString, true); //true means no proxy    System.Net.WebResponse resp = req.GetResponse();    System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());    return sr.ReadToEnd().Trim(); } Here's a POST: public static string HttpPost(string URI, string Parameters) {    System.Net.WebRequest req = System.Net.WebRequest.Create(URI);    req.Proxy = new System.Net.WebProxy(ProxyString, true);    //Add these, as we're doing a POST    req.ContentType = "application/x-www-form-urlencoded";    req.Method = "POST";    //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&    byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);    req.ContentLength = bytes.Length;    System.IO.Stream os = req.GetRequestStream ();    os.Write (bytes, 0, bytes.Length); //Push it out there    os.Close ();    System.Net.WebResponse resp = req.GetResponse();    if (resp== null) return null;    System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());    return sr.ReadToEnd().Trim(); } > I could and should have put in more 'using' statements, but you get the gist. And, there are other ways to have done this with the BCL, but this is one. Now, how would you fake an HTTP PostBack? Use a tool like ieHttpHeaders to watch what a real postback looks like, and well, fake it. :) Just hope they don't require unique/encrypted ViewState (via ViewStateUserKey or EnableViewStateMac) for that page, or you're out of luck. [...]

Being a good .NET citizen means certain things...start with your debugging skills

Fri, 03 Dec 2004 07:10:09 GMT

I've not been one to work the newsgroups, answering questions. I probably should. I'm more of a one on one person, and I tend to go the extra mile when folks (largely strangers) ask me technical questions. I've had email threads 10-deep with total strangers on technical questions, and only at the end do I say, "Um, do I know you?" I haven't done what Scott Mitchell wisely did and setup a "Getting Help" policy, but I'm quickly getting there. I'll happily answer your question for $75 too, satisfaction guaranteed, and I'll blog the answer. I've done this hundreds of times for free. :) Anyway, the point of this post was this: People, for crying out loud, debug a few things before you ask for help. If you don't know how to debug, learn or ask someone to teach you. So, I present: The Hanselman List of .NET Debugging Dos and Don'ts Don't - Say "Hey, I got a NullReferenceException," what's the problem? Do - Provide a Stack Trace/Dump with the line number it likely happened on. Don't - Get deep into your complicated program, find a bug and insist it's BillGs fault. Do - Reproduce the bug in some simple test program and tell the world. Remember, 9/10 times it's you. Don't - Decide there's a problem if you don't know the preferred behavior. Do - Always Assert your assumptions. If null can happen, check for it. BUT, if null must never happen it's time for a Debug.Assert Don't - Move code around blindly, somehow fix your bug, ignore it and keep coding. Programming by Coincidence! Do - Understand your program fully. Remember what Andy and Dave say about lucky folks who step into minefields and don't die. Just because you didn't die, doesn't mean there aren't mines! Don't - Reformat or "pave" something because you don't know what's wrong. If you get a spot on your carpet, fix the spot. Don't lay new carpet. Do - Know enough about your environment to know what your program's dependencies are. If your registry settings can get boogered, Debug.Assert that you are getting good values from the registry. Don't - Get overly frustrated with Assembly loading/versioning/policy. At least the Assembly Loader follows clear, set, rules. Do - Make a folder called C:\FusionLogs, then go to the registry in HKLM:\Software\Microsoft\Fusion and make a DWORD value LogFailures=1 and string value LogPath=C:\FusionLogs. Every AppDomain that has a binding failure or weird redirect will get logged. Know: What assembly you want, what they looked for, what you got. Know where Assemblies are searched for. Don't - Avoid debugging. Debugging in .NET is easier than ever before. Remote debugging and AttachToProcess are gifts. Don't stop at a point in the call stack if you can keep going by finding PDBs. Do - Keep your Source and PDBs in the same location. We keep ZIPs of every build's PDBs. Just today we dug up 9-month old PDBs and source (from CVS) to debug into some confusion. Not saving those PDBs would have screwed us. Create a Symbol Server. Don't - Limit yourself to the QuickWatch. Learn what VS.NET has to offer. Do - Use the Immediate Window to test theories. Remember that you can perform Casts in the Watch Window. Remember that you can drag and drop variables into the Watch Window. Remember you have 4 Watch Windows, Autos, Locals, not to mention. Learn how to use Conditional Breakpoints! Don't - not debug something just because you can't figure out how to launch the process from the VS.NET Project Properties. Do - Debug|Processes|Attach to attach to processes that have your DLL loaded. Use ProcExp from SysInternals as a better Task Manager to see .NET processes, as well as a system-wide DLL search. Who's got you loaded? [...]

FireBlogging - The View From My House

Thu, 02 Dec 2004 09:10:27 GMT

It's 1:09am on Thursday, December 2nd 2004, and here's the view from my bedroom window. The house next door is burning and we share a wooden fence. Pretty exciting stuff! Fortunately, I'm not too worried, I'm in a family of fire-fighters.

(image)  (image)

(image)  (image)

P.S. For those of you not in the U.S., most, if not all, residential housing (especially in the Suburban Western U.S.) is made of wood and quite flammable. My wife's still not used to this fact, and her family isn't impressed that our family fights fires. :)


Adobe PDF Reader slower than Molasses? Speed up Acrobat Reader 10x+

Thu, 02 Dec 2004 05:29:16 GMT

Here's a great little free util that Omar has found.  I used to move the plugin's manually to speed things up, but PDF Speedup makes me NOT DREAD opening a PDF anymore. BTW, does Acrobat 6 suck LOTS more than Acrobat 5? I HATE the new Find Dialog.

I have previously written about how darn slow Adobe Acrobat 6 is when launching. I don't understand why Acrobat is so darn annoying. Here are some things I don't care for:

* Don't create a “My eBooks“ folder in My Documents when I have nothing to put there.
* Don't load 500 plugins when none of them are necessary to view a PDF
* Don't place shortcuts for some lame Internet Printing thingy in my Start Menu (I loathe Start Menu Advertising)
* Do install a PDF IFilter so that indexing products like Lookout can index PDFs w/o installing it seperatley
* Don't load PDFs in IE because it is god awful slow
* Don't make copy and paste so freaking hard
* Don't ask me to install other Adobe software when I boot Acrobat
* Don't create an updater (6.0.2) that creates an additional entry in my add/remove programs

If you want to fix most of these things, PDF SpeedUp is a free application that should come bundled with Acrobat. It's a must have piece of software to make Acrobat behave (as much as you can anyway).


NUnit Unit Testing of ASP.NET Pages, Base Classes, Controls and other widgetry using Cassini (ASP.NET Web Matrix/Visual Studio Web Developer)

Wed, 01 Dec 2004 01:44:16 GMT

There's a lot of info out there on how to cobble together NUnit Unit Testing of ASP.NET Pages and assorted goo. NUnitASP is a nice class library to facilitate this kind of testing, but it doesn't solve a few problems: Do you have/want a Web Server on your Test/Build machine? How do you get your Test Pages and such over to the Web Server? Just automatically copy them? Are your Test cases self-contained? That is, do they require external files and other stuff to be carried along with them? I have a need to test a number of utility classes, base classes for System.Web.UI.Page and other miscellany and I'd like the tests to be entirely self contained and runnable only with NUnit as a requirement. So, here's a small solution we use at Corillian. I use Cassini, the tiny ASP.NET Web Server that brokers HTTP Requests to System.Web.Hosting and the ASP.NET Page Renderer. You may know Cassini as the precursor to the Visual Developer Web Server from Visual Studio "Whidbey" 2005. Cassini usually comes with two parts, CassiniWebServer.exe and Cassini.dll.  However, I don't want to launch a executables, so I'll just refer to Cassini.dll as that is the main engine. using Cassini;       [TestFixture]     public class WebTests     {         private Server webServer;         private readonly int webServerPort = 8085;         private readonly string webServerVDir = "/";         private string tempPath = AppDomain.CurrentDomain.BaseDirectory;         private string tempBinPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"bin");         private string webServerUrl; //built in Setup Cassini is the 'private Server webServer' in the code above. I'm using a fairly random port, but you could certainly scan for an open port if you like. Note that I'm building a /bin folder, as Cassini's own ASP.NET Hostingn AppDomain will look for DLLs to load in /bin. Cassini starts up another AppDomain, and that AppDomain then loads Cassini.dll AGAIN, except the new AppDomain has a different search path that includes /bin, so it won't find Cassini.dll in the current directory. Usually this problem is solved by putting Cassini.dll in the GAC, but I want this test to be self-contained, and since I'll need my other DLLs in /bin anyway... [TestFixtureSetUp] public void Setup() {     //Extract the web.config and test cases (case sensitive!)     ExtractResource("web.config",tempPath);     ExtractResource("test1.aspx",tempPath);     ExtractResource("test2.aspx",tempPath);       //NOTE: Cassini is going to load itself AGAIN into another AppDomain,     // and will be getting it's Assembliesfrom the BIN, including another copy of itself!     // Therefore we need to do this step FIRST because I've removed Cassini from the GAC       //Copy our assemblies down into the web server's BIN folder     Directory.CreateDirectory(tempBinPath);     foreach(string file in Directory.GetFiles(tempPath,"*.dll"))  &n[...]

Opportunity: Windows is completely missing the TextMode boat...

Wed, 01 Dec 2004 00:11:46 GMT

With all this talk of shiny Avalon, I'm surprised that more people aren't mentioning "text-mode" applications.  I assume we all realize that there are literally millions of Windows machines from 95 to XP that exist only to allow more than one Telnet/ProcommPlus/Terminal window at a time, so end-users can interact with remote systems.

Point of Sale is a huge example:

  • Blockbuster Video – I'd hate to have the video store guy have to reach for a mouse and click on a Gray Screen button OR a shiny Avalon Form.
  • Toyota Service – Searching for Parts, making service appoinments, it's considerably faster in text mode than any *.*Forms technology, and I've seen them open as many as 8 windows at a time.
  • Teller Banking Systems – Many banks are changing their TextMode systems over to intranets, and I personally waited 90 mins at a large bank last week to open a checking account, while I watch the teller move between three intranet ASP applications and two Word Macros, then attaching the Word files to an Outlook Email.  This same process, in text mode, at First Technology Credit Union took 10 mins. 

I'd like to see how far someone could take the new Colored Console support in Whidbey and make me a forms renderer. 

I’m just saying that my Tab,Tab,Tab,Enter will beat your Click,Tab,Alt-F,O,Click,Double-Click, more often than not and I will take the Pepsi Challenge otherwise. :) 

Am I nuts to think that Windows is missing the text-mode boat?


QuirksMode Bug Reports - CSS and JavaScript Weirdness Search Engine

Tue, 30 Nov 2004 19:28:26 GMT

Here's a darned useful thing, the equivalent of a KB Serach for CSS and JavaScript bugs.

This is very useful: QuirksMode Bug Reports, "entirely dedicated to finding, mending, and publishing CSS and JavaScript browser bugs." You can search by browser or by keyword, or just go to that page to see the last seven reported bugs. [WebStandards]



TestDriven.NET 1.0 Launch - What are you waiting for?

Mon, 29 Nov 2004 20:34:51 GMT

(image) It just kills me - literally tears me up inside - to watch people with both NUnitGui and Visual Studio.NET open who painfully switch back and forth, opening DLLs, attaching to processes, and generally cobbling together a sense of TDD.

Tell me you wouldn't rather right-click and say "Run Test" or "Test With...Debugger."

You may have used NUnitAddIn, which was a godsend. Today, Jamie and team launched TestDriven.NET 1.0 with full support for NUnit, csUnit, MbUnit AND Visual Studio Team System.

Naysayers may dismiss TestDriven.NET as a simple Add-In with modified right-click context menu, but there's much more than that. You run your tests in their own runner process, which gives you side-effect free testing. If you have different projects using different testing frameworks, their tests are all runnable with the same right-click/"Run Test" experience.  You can right-click on a single method and debug it. I love it.

You can run tests with NUnitGui, sure, but the Visual Studio integration goes very deep. I even show this integration in sales meetings. When you hit Build, the output window's combobox says "Build", of course. When you "Run Test" you'll see "Build" then "Test" immediately. This is what folks were aiming for when continuous integration and TDD.

I literally don't know how I managed before TDD, and you'll have to pry this free tool from my cold, dead hands.

Thanks Jamie and Team, this is great stuff.

I particularly like the last question in the short registration/survey, and I wish more people would ask it!

  • How did you answer these questions? (it will *not* be held against you!)
    • I answered them honestly
    • Randomly to get to the download

Scott Hanselman's Holiday List

Mon, 29 Nov 2004 06:42:41 GMT

I'm beating the Christmas/Chanukah/Kwanzaa/Festivus rush, and posting my wants-list now. :) This is also known as my stuff-I-may-buy-if-you-don't-give-it-to-me list. Enjoy. In no particular order. Games Tom Clancy's Ghost Recon 2 - I'm loving the squad-based shooters Prince of Persia 2 - I'm about 85% through the first one, and it's the best 3D platformer ever Burnout 3 - Never heard of it, but the folks who play it won't shut up about it and it would be one more game to use my Xbox Wheel Controller Nintendo DS - I think I'll wait until the frenzy dies down, but this seems too cool not to have. I'd probably get Mario, and Rayman. Might be time to start taking the bus to work... Music and Books Adrianna Evans - I dig the neo-soul Meshell Ndegeocello - Smooth sounds Davina - More music that somehow never hits the radio Amel Larrieux - Come on, people, you at least remember Groove Theory? Van Hunt - Heir to Marvin's throne... Anything from this neo-soul list...although I have most of these... Abraham : A Journey to the Heart of Three Faiths - So I can give my borrowed copy back > Electronics iPod 60gig Photo - My 15gig is totally full, and I'd love to move photos from my camera when on long trips. I hate thinking about storage Airport Express - I wouldn't mind streaming some music to the downstairs stereo either Altec-Lansing iPod Portable Speakers - My speakers at work are crap... Actually, scratch that last one, I'd rather have a Tivoli iPal Casio Exilim EXZ55 - Can't say enough nice things about the Exilim series Panasonic SA-XR50 - One of the first truly digital receivers. There's no DAC! The wife will never let me get this 37" LCD HD TV Gadgets and Misc Anything from Any Phidgets, but especially the Motion Sensor and Interface Kit 8/8/8 with Power Supply A CFA634-TMC-KU so I can hook it up to iTunes [...]

Today's Quote - "The Internet combines the excitement of typing with the reliability of anonymous hearsay."

Fri, 26 Nov 2004 01:31:39 GMT

"The Internet combines the excitement of typing with the reliability of anonymous hearsay."
America (The Book): A Citizen's Guide to Democracy Inaction


Attention Bloggers: If you're not reading the Daily Grind, why not?

Wed, 24 Nov 2004 18:24:29 GMT

I am subscribed to 168 RSS feeds.  I'm obviously creating work for myself, which may not be a good idea. Having only a 4k stack myself, I can't hold a lot of URLs in my head. Additionally, sometimes I just want to visit a website myself.

Here's the websites that I actually launch a browser for every morning (I have a macro in Slickrun called "morning" that does this):

You have to give props to MikeG for (at the time of this blogging) 507 Daily Grinds.  I always find something interesting and useful in his daily rant. If you're a reader of mine, you should be a reader of Mike's as well. Here is the Daily Grind RSS Feed for your convenience: (image)


Setting the Title of the "DOS" Command Prompt from a Batch File

Mon, 22 Nov 2004 19:08:28 GMT

Just a small reminder for myself and others that you can set the title of the Command Prompt Window with the "TITLE" Batch Command.

Since I'm building three different branches of our SDK during dev, it's nice to differentiate all these windows on all these monitors.

For example here's "mybuild.bat"

TITLE Building VoyagerFramework 2.0
set BUILDDIR=C:\dev\VoyagerFramework\build
call BUILD.BAT %1 %2 %3 %4 %5


A Hanselman Review: Doom 3 vs. FarCry vs. Half-Life 2 vs. Halo 2

Mon, 22 Nov 2004 02:36:19 GMT

Believe it or not, I'm not a big gamer.  By 'not a big gamer' I mean, I didn't take a week off work to play GTA: San Andreas as a co-worker did.  By 'not a big gamer' I mean, I lost interest with Ninja Gaiden because it was too freaking hard. I've got about 2 hours patience with a game, but I stop when I start to hurt, be it hands, back or head. That said, you'd think I was a gamer as in the last two months I've picked up Doom 3, FarCry, Half-Life 2, and Halo 2. These games, unquestionably, represent the pinnacle - thus far - of FPS-style gaming. The first three are PC while Halo 2 is on XBox. I'm playing the PC games on a P4-4Ghz with a gig of Ram and an ATI Radeon 9600 Pro. There's been a million reviews of all these games from AnandTech-type reviews that tell you how much internal processor cache you must have to enjoy these games, to TomsHardware-type reviews that are meant to sell $500 video cards with heat sinks and fans of their own, to 12-year old blogger/reviewers who let you know about the latest mods and cheats so they can embarrass my 30-year old ass on multi-player maps. (You'll be happy to hear that I (and my ego) no longer need to defeat these infidels to feel secure. I just cry tiny tears and leave it at that.) That said, I wanted to write up what I thought was important about these games, and what drives my opinion and buying decisions around gaming. These categories may be slightly different than the typical review. Or not. Story Game My Thoughts Doom 3 While Doom 3 tries harder than it's predecessors, there's little story to speak of. Some crazy stuff happens on Mars and you're a Mars Marine who has to single-handedly kill everyone. There are some interactions with other characters but it's largely as you stumble upon them doing something else, and you can't assist them. They are usually killed as you walk away. The "scripting" feels a little stilted to me. There are a few clever places where the camera backs out of your first-person view into a third person view when you "trigger" an event. Perhaps a monster is making in entrance. Then the camera pushes in to the back of your head and control returns to you to take care of business. It's fairly predictable as you can "feel" when it should happen. FarCry You'll notice a pattern here as "single-handedly" is pretty common in the FPS space. In FarCry, you're on vacation when your wife is kidnapped and you are unwittingly and unwillingly pulled into a terrorist plot to do some crazy stuff. You have to single-handedly kill everyone.  Every once in a while, a benefactor in the form of a scientist on the project meets up with you to help out. Half-Life 2 The original Half-Life set a whole new level for story quality and I believe Half-Life 2 is even more extraordinary. There is constant interaction with the NPCs and a real sense of total immersion that I honestly haven't felt since "Bard's Tale." There's many places where you find your self asking "what's the story here? There's something [...]