ASP.NET – Build Times for Small Incremental Changes to C# Web Applications

asp.netasp.net-mvcperformancevisual studio 2010web-applications

I have recently been moving away from ASP.NET Websites in favor of Web Applications. More specifically I have recently been picking up MVC as an alternative to developing ASP.NET Forms websites.

Something that I find highly frustrating is the constant build->change->re-build process when testing small changes to compiled code. I find myself 'bundling' several changes between builds just to avoid waiting 20-25 seconds for Visual Studio to crunch it's way through the compilation process. I created a clean MVC 4 project from the VS template and timed the build after making a single line code change, it took 19 seconds.

When making a change in the code-behind in an ASP.NET website I've always found that the page is seemingly re-compiled on the fly when you next hit the page. This would seem to me to be a better environment for web development rather than VS forcing an entire rebuild after every small code change.

In the past I have enjoyed the luxury of making a change, hitting refresh in the browser, and waiting 1-2 seconds for my result. Is this achievable with web applications built using Visual Studio?

Best Answer

You can edit your MVC views while the site is running. The code for controllers and everything in between must be recompiled after a change. Did you write everything in the .aspx when using ASP.NET?

Anyway, 20 seconds is quite long for an incremental build after changing a single line of code (though it might depend on what you changed, it may cascade through a few assemblies). I'd try to address compilation speeds first. Why is it taking long? NuGet package restore? Copying lots of assemblies? Slow disk drive, CPU and low on memory?

On the other hand it sounds like your development practice is a bit suboptimal. You might want to employ test driven development, where you write a test to show what your intentions are, after which you start working on the implementation. This way you won't also have to wait for the development web server and the browser to start; you run the tests from Visual Studio.

Related Topic