Use HostingEnvironment.MapPath

Jun 25, 2010

When running a service under IIS, the HttpContext.Current object is not available, so HttpContext.Current.Server.MapPath will fail.

fileName = HttpContext.Current.Server.MapPath(fileName);

The solution is to use Hosting.HostingEnvironment.MapPath instead.

fileName = System.Web.Hosting.HostingEnvironment.MapPath(fileName);

Custom Controls In ASP.NET

Feb 26, 2010

ASP.net has that neat little feature where all the controls can start with <asp:.  It makes it easy to code.  I had numerous custom controls and I always had to register the control on each page to use it.  Scott Guthrie had a great tip on how to register the controls in the web.config file so that it doesn’t have to be done in each page.More...

MSDN Style Class Documentation

Jan 20, 2010

NDoc is dead. Long live NDoc! How to generate MSDN style documentation using Sand Castle on Visual Studio 2008. More...

Features, Flags, Updates And Branches

Dec 03, 2009

Version control systems are wonderful tools and terrible tools all depending on the process used to manage the files stored in them.  They allow tracking changes, updates, reversing updates, comparing to older updates, and creating multiple branches and variations of files ad-infinitum.  What are good rules to keep good tools from going bad?More...

Date And Time Tracking in .Net

Sep 28, 2009

Getting the right date and time sounds simple enough, but when you look at a few interesting scenarios with multiple teams coordinating actions across multiple time zones with multiple clients and servers, designing for the date and time for a given event becomes complicated very quickly.  I’d like to share an some approaches that I think work well in .Net.More...

Fields to Properties

Jul 24, 2009

How to automatically have Visual Studio 2008 convert fields to properties. More...

Pretty Good URLs

Mar 13, 2009

With a little forethought and planning, it’s possible to create URLs that can be around the web for a long time and as Tim Berners-Lee pointed out cool URIs don't change.  Choose wisely though, you may have to live with the URLs for much longer than you think, or if your not careful, you may end up with too many URLs pointing to the same content. More...