Skip to main content

Posts

Showing posts from 2009

MailAddress can't eat its own dogfood

Just found out today that System.Net.Mail.MailAddress (.Net 2.x/3.x) can't "eat its own dog food"; very frustrating. Previously I decided that rather than waste my time trying to come up with a good email address validation routine, I'd use the one in MailAddress's constructor. (It has to go through there at some point anyhow.) I thought I got the additional bonus that it would actually normalize/fix some addresses it considered valid/OK/good enough. Unfortunately, I later found out that the constructor doesn't always like what it (itself) changes the address to. MailAddress ma = new MailAddress("x y@z.com"); // ma.Address is "\"x y\"@z.com" at this point... ma = new MailAddress(ma.Address); // this will throw an exception. Now my validation routine has to send it through twice. This is to make sure that I never have to worry if subsequent code uses the "Address" value instead of the original.

Reclaiming disk space in Vista

Normally, I expect my drive to be rather bloated from all the iso files I keep around, but on occasion I try to clean things out. My latest attempt came from a desire to fit everything in under 80GB so I can buy an SSD (I was at 110GB). This laptop is running Vista x64 Business, SP2 with 3GB RAM. WinDirStat I always start by looking at the disk space usage. I previously used TreeSize, but now I use WinDirStat ; free and I prefer it now. I ran it as Administrator (so the counts were as accurate as possible) to see where all the space was going. I first used the Windows Disk Cleanup utility (though I skipped the Recycle Bin), but after that, most of the good information came from " Where's all my disk space going in Vista? ". Volume Shadow Copies This ended up commanding the largest space, and you can only "see" it as an Administrator since the files are in c:\System Volume Information . This page has good information about it: " Adjusting the amount of disk

"Content-Encoding: gzip" failure for IE

Oh boy. I became aware of another crippling bug with Internet Explorer today (IE6, IE7, & IE8). In short, when downloading a .zip file that is transmitted using gzip encoding, IE doesn't unpack it before passing it on to the end-user. So instead of getting a .zip file as expected, you get a gzip file that contains the file you wanted to download. To the average client, it appears that the file is corrupted---and in the end, that's all that matters. Based on the various discussions found when Google-searching for "gzip ie7", it appears the problem is (at least) in the Vista versions of IE. I happen to be on Vista x64 SP2 and IE8, so that's at least one environment where the bug is present. The server is irrelevant, but if you must know, I'm using IIS 6 (Windows 2003 Server) with .Net 2.0; the page's extension is ".aspx", but I use the content-disposition header to give the download a ".zip" extension. There is this one page where so

IE7 and no-cache HTTP headers

If you ever want to make it so IE7 will not download a file, set the Cache-Control or Pragma headers to "no-cache". Some time in the past, I thought I learned that when you want to stop a proxy server from caching a file (apart from or in addition to the actual client), you set the following headers: "Cache-Control: no-cache" and "Pragma: no-cache". In C# ASP, that equates to the lines Response.Cache.SetCacheability(HttpCacheability.NoCache); and Response.AppendHeader("Pragma", "no-cache"); (I believe the Response.Cache.SetMaxAge(TimeSpan.Zero); line was also suggested to me as part of this, but I can't remember anymore.) If you send either of those 2 headers, you'll get a completely useless error message from IE7 when clicking a link to the page---you'll see "Internet Explorer cannot download filename from domain/server ... Internet Explorer was not able to open this Internet site. The requested site is either