Wednesday, September 23, 2009

Introduction to Unit Testing

This is a training I provided to other developers on my team on how to get started with unit testing and test-driven development.  This is Part 2 of 3 in a series of talks geared towards improving code quality at my organization. 

Part I – Introduction to Design Patterns as a Best Practice

Part III – Coming soon, and will cover more advanced unit-testing topics including mocking (Rhino Mocks), refactoring, and more sophisticated unit test strategies.

Download Presentation and Source Code:

  • PDF version of my presentation
  • Visual Studio 2008 solution containing sample code and unit tests.

Friday, September 4, 2009

Enabling HTTP Compression for ASP.NET and IIS 6

I just went through the process of enabling HTTP Compression for 2 ASP.NET applications running under Windows Server 2003 and IIS 6, so I thought I’d share a summary of the process.

Huge thanks to Robert Boedigheimer for his assistance with this process.  I attended his excellent Things Every ASP.NET Developer Should Know session at devLINK last month and then he helped me work through the particulars.

Robert also explained to me how to determine if my site (internal) is using HTTP Compression.

  1. Start Microsoft’s Network Monitor.
  2. Open a “New Capture Tab”
  3. On the toolbar click “Start” to start a trace.
  4. Using any browser, browse to a web page for the site in question.
  5. In Network Monitor, click “Stop” in the toolbar.
  6. In the “Display Filter” panel, type “http” (no quotes) and Apply.
  7. Find the Response frame in the middle panel.  Select that frame, then examine the Hex Details frame.
  8. To the far right in the Hex Details frame, you should see that Content-Encoding is gzip.

Other good references:

I created a batch file that will perform the entire HTTP Configuration process.  Here are the overall steps:

  1. Stop IIS.
  2. Backup the MetaBase
  3. Create the temporary folder to contain the compressed files, and set the max folder size
  4. Update the MetaBase with the new settings
  5. Restart IIS.
  1: @ECHO OFF
  2: iisreset /stop /noforce
  3: MKDIR "E:\IIS Temporary Compressed Files"
  4: cscript.exe iisback.vbs /backup /b BeforeHttpCompressionChange
  5: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoStaticCompression TRUE
  6: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoDynamicCompression TRUE
  7: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoOnDemandCompression TRUE
  8: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcNoCompressionForHttp10 TRUE
  9: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcNoCompressionForProxies FALSE
 10: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcNoCompressionForRange FALSE
 11: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcCompressionDirectory "E:\IIS Temporary Compressed Files"
 12: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcMaxDiskSpaceUsage "52428800"
 13: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoDiskSpaceLimiting TRUE
 14: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcDoStaticCompression TRUE
 15: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcDoOnDemandCompression TRUE
 16: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcDoDynamicCompression TRUE
 17: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcFileExtensions "css" "doc" "htm" "html" "js" "txt" "xml"
 18: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcScriptFileExtensions "asp" "ashx" "asmx" "aspx" "axd" "dll" "exe" "svc"
 19: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcOnDemandCompLevel 9
 20: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/deflate/HcDynamicCompressionLevel 9
 21: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcDoStaticCompression TRUE
 22: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcDoOnDemandCompression TRUE
 23: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcDoDynamicCompression TRUE
 24: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcFileExtensions "css" "doc" "htm" "html" "js" "txt" "xml"
 25: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcScriptFileExtensions "asp" "ashx" "asmx" "aspx" "axd" "dll" "exe" "svc"
 26: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcOnDemandCompLevel 9
 27: cscript.exe adsutil.vbs Set W3SVC/Filters/Compression/gzip/HcDynamicCompressionLevel 9
 28: iisreset /start
 29: PAUSE