13 October 2005 10:24
, .NET 2.0
It seems to me that lots of features have been "simplified" (I prefer the term dumbed down ;)) in developing web sites under Visual Studio 2005. The following are examples that I've found so far:
Web site projects do not and cannot have a default namespace specified in the project properties and in fact by default pages and controls are not created in a namespace. You can put your page/control classes inside namespaces, but you have to manually update the page/control directive. Interestingly this is in violation of one of the Design Guidelines (CA1050) enforced by the Code Analysis tool, which states that all public or protected types should be declared inside a namespace to prevent naming collisions and to organise related types in an object hierarchy, but this violation is not reported by the Code Analysis tool in web site projects.
This leads me on nicely to the next point. For Web site projects you can only specify whether or not you want Code Analysis to be run, you cannot customise the rules in the same way as you can for other projects.
And also on the topic of declaring types in namespaces; if you use the new Profile features provided in ASP.NET 2.0 you get a class called ProfileCommon automatically generated for you which provides strongly typed access to the profile properties that you specify in web.config. However this class is not declared inside a namespace and does generate a CA1050 violation.
One more thing before I go: server controls created on pages and in user controls used to be declared in the code behind as protected members, and event handling used to be registered in the OnInit method. This is no longer the case. Event handling is declared in the control declaration in the aspx page and server controls aren't explicitly declared they "just exist". I'm all for writing less code, but I'm not convinced this is a step forward yet.