A common question by asp.net developers is what project model should I use for asp.net application? Web Site project (which introduced with VS 2005) or Web Application project (which delivered as add-in for VS 2005 and built-in within VS 2005 SP1)?
There is no thumb rule. Every project model has it's own advantages (and diss-advantages off course...). I hope this post will help you to understand better the differences between 2 of them.
Web Application project model
- Provides the same Web project semantics as Visual Studio .NET 2003 Web projects.
- Has a project file (structure based on project files).
- Build model - all code in the project is compiled into a single assembly.
- Supports both IIS and the built-in ASP.NET Development Server.
- Supports all the features of Visual Studio 2005 (refactoring, generics, etc.) and of ASP.NET 2.0 (master pages, membership and login, site navigation, themes, etc).
- Using FrontPage Server Extensions (FPSE) are no longer a requirement.
Web Site project model
- No project file (Based on file system).
- New compilation model. (Read here or here for more details) and ...
- Dynamic compilation and working on pages without building entire site on each page view.
- Supports both IIS and the built-in ASP.NET Development Server.
- Each page has it's own assembly.
- Defferent code model. (Read here for more details)
Ok, all is great, but you want to create your web site now. Which model should you use?
- You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
- You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
- You need to add pre-build and post-build steps during compilation? use Web Application project.
- You need to build a Web application using multiple Web projects? use Web Application project.
- You want to generate one assembly for each page? use Web Site project.
- You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project.
- You prefer single-page code model to code-behind model? use Web Site project.
10 comments:
Thanks, I've been looking for the cut and dry answer to this for a while. Lots of people could tell me a few differences, but you have finally compiled enough info for anyone to make their decision.
Thanks
This is the best summary I've found on the subject. Thanks!
My issue with website vs. project is the fact there are now source files on the production server. Using DLLs prevents someone with server access messing with your code.
Great topic, very good and precise answers.
Thank you!
Can anyone add a couple more variations?
My primary concerns are that I want all of the source code together under one subdirectory for sourcesafe or vault to share correctly with other team members.
And I do not want source code on the server.
So which should I choose?
Thanks for this summary. It is concise and easily understandable. I now know that the Application model is preferable (with an obfuscator) to protect my source code and techniques.
I would add the following distinction:
If you update your project as a whole and manage versions of your project, use Web Application.
If you need to periodically update parts of your site (add or update pages), use web site.
I have not investigated this too much, but since a web application project compiles your files by default, I don't think the website can dynamically load user controls from the file system.
This could be one of the things to take into consideration when choosing between the two types of projects.
Ciao!
And if you need XML documentation, go with Web Applications.
Post a Comment