The purpose of this blog post is to announce that the Sitefinity 4.0 CTP Project Manager now creates Web Application Projects. [Get to the point.]
However, before I get to this, I have a confession to make: I’ve spent most of my career in the PHP and Perl world. In these environments, there is no such thing as a “project”. All code is dynamically compiled at runtime.
As a result, web development looked a lot like this:
1. Edit the code
2. Refresh the page in the browser
3. See the changes
This workflow became embedded in my head for many years. When I migrated to the ASP.NET I continued to follow this workflow. Watch any of my Sitefinity videos and you’ll see me doing this constantly. All of this worked fine until I stumbled into a Web Application Project.
Where are my changes?
I was able to use the workflow described above because Sitefinity 3.x used Web Site Projects. Web Site Projects are file-based, not project based. Any file placed in the web site directory automatically becomes part of the pseudo project. Furthermore, any code-changes get compiled dynamically when accessed for the first time.
However, there is another ASP.NET project type known as Web Application Projects. Web Application Projects are true Visual Studio projects. Files located in the project directory can be excluded from the project. All project code is compiled into a single DLL. Furthermore, this compilation does not happen automatically. This means, after code is edited, clicking refresh in the browser accomplishes nothing.
As a result, workflow in a Web Application Project looks different:
1. Edit the code
2. Press F5 in Visual Studio (build and start debugging)
3. Wait… Wait… Wait…
4. Default page opens up in the browser
5. Wait… Wait… Wait…
6. Re-navigate to whatever page I was interested in testing
7. See the changes.
8. Press Shift + F5 (Stop debugging)
There are short-cuts to this process. For example, you can leave the web browser open and then use F6 to simply rebuild the solution. Even with these shortcuts I’ve not been able to reproduce the sheer simplicity of merely refreshing the web browser for the latest changes. Suggestions?
What are the advantages?
At a glance, it looks like Web Application Projects involve a lot more work. I, personally, spent several months hating them. Web Application Projects inserted extra steps into my cause & effect development workflow. However, as my projects grew in complexity, I discovered a handful of advantages to Web Application Projects.
More predictable (and accessible) namespaces
Many months ago I wrote a blog post describing how to create a ControlDesigner for Sitefinity 3.x. The blog post described how to create a base class (in ~/App_Code) to facilitate communication between the UserControl and the Control Designer. This trick is necessary because, in a Web Site Project, UserControls are compiled dynamically and only exist in the namespace while actively in use.
To overcome this limitation, I used App_Code and a special Base Class to bridge the gap between these 2 dynamically compiled controls. This is confusing and painful.
In a Web Application Project, this trick isn’t needed; the entire project is compiled in advance (not at runtime) and all UserControls (and their public properties) are accessible without any App_Code tricks.
The project source code isn’t sitting on the server
Because all code is compiled into a single DLL, I don’t need to deploy raw source code to the server. This makes is very unlikely that code will get changed outside the formal build & deployment process.
Web Application Projects work like other Visual Studio projects
In my own opinion, the main advantage (or disadvantage) is that Web Application Projects work like other Visual Studio projects. By contrast, Web Site Projects are a bizarre aberration. This will probably seem great to Microsoft developers and will probably feel foreign to PHP, Perl, Python and Ruby developers.
Microsoft created a very helpful article that compares Web Application Projects to Web Site Projects. I also found a helpful question on StackOverflow. These two resources explore the differences, advantages and disadvantages of these two project types.
Formal support for both ASP.NET project types
It has always been possible to convert Sitefinity 3.x Web Site Projects to Web Application Projects. However, several Sitefinity customers requested that we formally support Web Application Projects (source 1, source 2, source 3). Telerik is delivering that formal support in Sitefinity 4.0.
The Sitefinity 4.0 CTP Project Manager creates Web Application Projects. However, the final release of Sitefinity 4.0 will offer a choice of project type. Customers will be able to choose the project type that best fits their development style.
What about you? Do you prefer Web Application Projects or Web Site Projects? Why?