asp.netvs-web-site-projectvs-web-application-project

ASP.NET Web Application forces rebuild on every back-end or code-file, making debugging time consuming and unusable


I always prefer using a ASP.NET Web Site over ASP.NET Web Application, as defined here: ASP.NET Web Site or ASP.NET Web Application?

It is suggested that only use 'ASP.NET Web Site' projects if you really need to (stackoverflow's tag says this); I would love to move away from this type of project, but the need to debug effectively and not waste time constantly recompiling projects for trivial changes makes me regret choosing the latter every time.

This is down to two key reasons.

  1. Whenever you make a change to a back-end file or code-file, you are forced to rebuild the project before the change is available. With the 'ASP.NET Web Site', back-end files would be available immediately, and code-files within the 'App_Code' directory would trigger an automatic background rebuild enabling changes to be available within the next request with no developer input.
  2. Because of this constant requirement to rebuild, you cannot make a change while debugging without stopping/starting the debugger (unless you perform an attach-to-process with a few tweaks). This is very frustrating, especially when the project gets to a certain size where the compile time makes this completely impractical. Not only that you lose all your debugging states, objects which were loaded in memory have been cleared, etc.

I'm pretty sure I am missing something, as if Web Applications are the preferred project type by the majority, how can this be with such limitations? Are there solutions for this or suggestions on how to perform a series of small changes while debugging without stopping the debugger then manually performing a rebuild each time? And is there a way to prevent back end files from needing a rebuild of the whole site? (I guess this is why 'ASP.NET Web Site' has a dll for every file or directory)


Solution

  • It is not a limitation, it's just how it works without the on-the-fly compilation of the WebSite template.

    You can use the Edit and continue feature of Visual Studio, but not every type of change is supported.