Welcome to Day 2 of my tour through ASP.NET 4.0. In this article, we'll be looking at the changes to the new web-related project templates available in VS2010 and see how most of them have been folded into the core VS product from various out of band projects released in the last five years.
Unless you're the kind of person that likes cranking out literally every line of code in your app, you'll be very comfortable using Visual Studio's item and project templates. Want to start writing a new web service? Start a project with a WCF application project template as your guide. Want to write a Windows Forms application? Use the WinForms template. And so on. Until recently, web developers have had two choices - a web site or a web application project. We'll not cover the difference between the two templates here - read here or here for more info - but safe to say that while both are still with us in VS2010, they are back in altered forms.
(A quick note here to say that the new VS2010 New XYZ dialogs are much nicer than their counterparts from VS2008. It’s much easier to locate the items you want and you can even sort the templates as well (joy!). However I’ve necessarily cut and pasted sections from both VS2008 (left) and VS2010 (right) dialogs for ease of comparison. If it looks scruffy, it’s my fault, not theirs.)
The New Project Dialog
Lots of changes here.
- The ASP.NET Web Service Application in VS2008 has been removed completely.
- The WCF Service Application from .NET v3.0 onwards has been relocated under WCF projects in VS2010.
- The two Dynamic Data projects from .NET 3.5 SP1 have been renamed presumably for branding and also to highlight that a Dynamic Data Web Application uses LINQ to SQL rather than the Entity Framework.
- MVC users will recognize the Empty and (not empty) MVC Web Application types from previous out of band releases since .NET 3.5 SP1, albeit now updated to present you with templates for the forthcoming asp.net MVC 2 release. The Empty project type provides the standard folders (empty), blank global.asax and web.config files and the standard jQuery and MS AJAX libraries for you to start with. The (not empty) project provides a working site to start with, implementing a simple membership model, master page, error page, and a couple of content pages to boot. Optionally, the template will also generate you a sample test project if desired. A good place to start if you’ve not used MVC before.
- Taking their cue from the MVC projects, the plain, one-page-and-a-web-config-file ASP.NET Web Application template in VS2008 has been replaced with an Empty and a (non-Empty) ASP.NET Web (Forms) Application project. In Solution Explorer, the Empty project type looks like this.
Meanwhile, the (not empty) Web Application project generates the following files.
Rather delightfully, web.config has debug set to true by default, so you aren’t asked to set it to debug as VS2008 would have done when you press F5 for the first time. Oddly, it’s still set to false for the (non-empty) website project template which produces the same site and functionality. Anyway, this is the site you’ll see once it has built and is running on Cassini.
The New Website Dialog
The changes in the New Website dialog (VS2008 on the left, VS2010 on the right) are much the same as the new project dialog above albeit with the apparent non-sequitur that the WCF Service template is still available here. However, as the new dialog doesn’t offer any subcategories beyond Visual C# and Visual Basic, there’s no place else it can go. Besides that, the changes are as mentioned earlier. The Empty Web Site template includes a web.config file which it didn’t previously and the (non Empty) Web Site template generates the site structure noted earlier rather than the web.config and a blank ASPX page.
In this post we’ve looked at the changes in the website and web application project types from VS2008 to VS2010 and in particular at the new Empty and not empty Web Application projects. Next time, we’ll have a look at the new look web.config. Happy coding!