Wednesday, December 17, 2008

Refactoring Asp.Net sites

I'm 1/2 way through refactoring an Asp.Net MVC site to use the new beta and noticed my solution compiling without any issues, but Asp.Net compilation errors appearing on run.

Visual Studio wasn't compiling the content of the asp.net pages. Instead they were compiled on demand. Nothing wrong there... Unless you do a big refactoring and need to find errors on those pages all up-front.

That's where the aspnet_compiler command line tool can come in and help. Basically it pre-compiles all pages in an asp.net application. I think the main reason is for performance reasons on a live environment, but it's fabulous for doing refactorings.

aspnet_compiler -p. -v /

executed from the root folder of your website will detect all errors in the markup.

Enjoy!