Also, my colleague Jesse Murray will be speaking about "SharePoint - The Right Way" at the Great Lakes Area .Net User Group Wednesday October 21 in Southfield, MI. This event is sponsored by Sogeti (so food will be provided). You can get more information here.

Edit: My VSTS 2010 / TFS 2010 talk scheduled for October 29 has been postponed to December 3. -Dave, 10/24

HopeMongers is attempting to connect people together via charitable donations. The web site HopeMongers.org allows individual contributors to donate small amounts of money (they use the term "Microgiving" to describe this) to individual projects that help the poor of the world.

By doing so, they eliminate much of the bureaucracy and cost that burdens many other charitable institutions. The projects that HopeMongers supports tend to be small in size and focused on an individual community. Examples include digging a well to provide clean drinking water for a village in Haiti; construction of a building to house an orphanage in Uganda; and a computer education center in South Africa.

"All the money that's donated to HopeMongers goes to the project" said lead architect Phil Japikse.

On the web site, each project lists the amount needed to fully fund it and the amount raised so far.

Sam Henry of Microsoft is the driving force behind this site and he has traveled around the world seeking, vetting and overseeing projects to show on the site.

But many others are involved in the development of the web site.

DiscountAsp.net donated the web hosting; SAAS hosts TFS and the build servers for free; and most of the development time was donated by dozens of talented developers. Those who didn't volunteer worked on the project at a discounted bill rate.

The development team was spread across the US and worked part-time, which presented a number of challenges. For instance, most of the collaboration took place between 10PM and 1AM Eastern time, via LiveMeeting. For those interested in the technology, the site is built using ASP.Net web forms built with JQuery, C# and NHibernate.

The site is now live and accepting donations. Visit http://www.HopeMongers.org to learn about the projects and to give a little. You can even donate to the HopeMongers project itself from the site.

I gave $10 to help provide clean drinking water to a village in Uganda and I feel better for having done so.

The ASP.NET MVC framework (which I will refer to as "MVC" in this article) encourages greater separation of concerns than the older ASP.NET web forms framework.

Some key differences between web forms and MVC are

ASPX pages in MVC have no code-behind files. This discourages developers from putting any business logic in the view.

By default, URLs in MVC do not point to a file on disc. Rather, they point to an Action in a Controller.

A controller is a class that inherits from System.Web.Mvc.ControllerBase.

MVC uses several conventions to find this class. First, it expects controller classes to be in the Controllers folder. Also, it expects a controller class name to end with "Controller". So if we tell MVC to look for a Product controller, it will look for the file Controllers\ProductController.cs or Controllers\ProductController.vb.

An Action is a method within a Controller class that returns a System.Web.Mvc.ActionResult. The ActionResult represents the View data that is available when MVC renders output to the client.

One way we can tell MVC to look for a controller is by typing a URL into the browser’s address bar. Doing this causes MVC to use the routing engine. I described the routing engine in a previous article. The default routing assigned to a new MVC project looks for a URL with the following format

Controller/action/id

When the routing engine encounters a URL formatted like the one above, it looks for a controller named after the first part of the URL; an action method within that controller named after the second part of the URL; and a parameter to pass to that method in the third part of the URL. For example, if the user typed the following URL into the address bar:

Customer/Details/1

, MVC would look for a class named CustomerController in Controller\CustomerController.cs (assuming we are coding in C#). If it found this class, it would look in it for a method named "Details" that returns an ActionResult and that accepts a parameter. It would then call the Details method and pass it the parameter "1".

The ActionResult returned by this method is used by the MVC View engine to render output to the client. I described MVC views in a previous article.

The code below is for a Controller Action method. It assumes the existence of the GetCustomer method that returns a single customer object.

The View method called in the code above returns a ViewResult – a class that inherits from ActionResult. By passing the Customer object to this method, the ActionResult’s Model property is populated with the Customer object. Properties of that object can then be used within the view.

Another way to pass data from the controller to the view is to populate the ViewData property. ViewData is a list of name-value pairs. You can populate this list in the controller and retrieve elements from it within the view. We can modify the Action method above to add to the ViewData list.

By default, this controller routes the user to a view with the same name as the Action in a folder named after the controller. In this case, MVC will look in the \Views\Customer folder for a file named either Details.aspx or Details.ascx. If it cannot find either of these files in that folder, it will search in the Views\Shared folder. Here MVC is using configuration again to determine where to look for files.

You can change the view MVC looks for by using an overload of the View method as in the following example

return View("CustomerDetails", cust);

The above line tells MVC to look for a view page named CustomerDetails.aspx or CustomerDetails.ascx in either \Views\Customer or \Views\Shared.

The ASP.NET MVC framework (which I will refer to as "MVC" in this article) encourages developers to work closer to actual rendered HTML than does the more traditional web forms ASP.NET framework. The web form framework abstracted away much of the HTML, allowing developers to create sophisticated web pages simply by dragging controls onto a design surface. In fact, with the web forms framework, it is sometimes possible for someone with no knowledge of HTML to build an entire web application.

But MVC’s view engine removes that abstraction, encouraging users to write more of their own HTML. By doing so, developers also get more control over what is rendered to the client.

Some web developers may be surprised to learn that most of the server controls they are used to dragging onto a design surface do not work in MVC. This is because ASP.NET server controls are self-contained objects that encapsulate all their functionality, including the C# or VB code they run. This is contrary to the way that MVC works. In the MVC framework, all business logic code is in either the model (if it applies to the data) or in the controller if it applies to routing or output.

An MVC view consists only of an ASPX page. By default it doesn't even contain a code-behind file.

Let’s analyze a typical MVC view. Like a web form, an MVC view contains a page directive at the top.

The Title, Language and MasterPageFile attributes should be familiar to anyone who has developed in ASP.NET. The meanings of these attributes have not changed in MVC. The Inherits attribute is also used in web forms development, but in this case, we are inheriting from a ViewPage that contains our model. The model represents the data we wish to render (I will write more about the MVC model in a future article.) By inheriting from a ViewPage, we provide the model data directly to the page and we can strongly type the keyword Model to whatever data type our model is.

Mixed in with the HTML of our page, we can output some server side data by enclosing it in <% %> tags.

If you wrote any web sites with classic ASP (the predecessor to ASP.NET), you probably used these tags. (I recently heard someone refer to them as "bee stingers"). If you place "=" in front of a value or variable, the view engine will output the value or contents of that variable. For example

<%=System.DateTime.Now %>

outputs the current date and time, like the following

10/2/2009 6:08:46 PM

We mentioned earlier that the Model keyword is strongly-typed. For example, If we inherit our ASPX from System.Web.Mvc.ViewPage<TestMvc.Models.Customer>, then our model represents a Customer object and we can output a property of that model class.

You probably already know that it is almost always a bad idea to output text directly for the screen without encoding it, as I did above. Failure to do so may leave your site open to scripting attacks. Fortunately MVC includes an Encode helper method to encode strings for safer output. That helper method (along with other helpers) is available via the Html property of the ViewPage from which our view inherits. We can call the helper method and encode the first name with the following markup.

<%= Html.Encode(Model.FirstName) %>

This outputs the FirstName property, but encodes it to prevent problems if the first name property somehow gets infected with some client-side script.

Other helper methods of the ViewPage give you the ability to begin and end an HTML form, to render an HTML textbox, to render a hidden field, to render an HTML listbox, and perform many other useful functions.

The code below will output a hyperlink with the text "Home" that links to the Index method in the Home controller.

<%= Html.ActionLink("Home", "Index", "Home")%>

Another way to use data in the view is to store it in ViewData. ViewData is a property of the view and contains a dictionary of name/value pairs. You can add a value to this dictionary in the controller with code like the following

ViewData["Greetings"] ="Hello dummy";

and display a ViewData element in the view with markup like the following

I am months late producing this video. But now that it's finished, I want to show it off. Earlier this year, my son's 8th grade basketball team tied for the city championship. Here are highlights from the season.

One of the differences between ASP.NET MVC and traditional ASP.NET web forms is the URL typed by the user.

In traditional ASP.NET, a URL points to a physical page on disc. Typically one can infer the location of that page by examining the URL. For example, the URL

/Folder1/MyPage.aspx

likely points to a file named MyPage.aspx located in a folder named Folder1.

By contrast, a URL in an ASP.NET MVC application points to an action in a controller. For example, the URL

/Customer/Edit/2

Tells the MVC framework to pass a parameter of "2" to an action method named Edit in a Customer controller class.

ASP.NET MVC (which I’ll call MVC going forward) uses routing to map a URL to a specific action. Routing is typically configured in the Application_OnStart method of the global.asax file. An MVC application contains a System.Web.Routing.RouteTable, which contains a collection of routes on which it can act. When you create a new MVC project, a default route is added to this collection by adding the following code in global.asax.

This code adds a route named "Default" to the route table. This route tells MVC to look for a URL structured similar to the following

Controller/action/id

When it encounters such a URL, it looks for a controller class with a name based on the first part of the URL. By convention, MVC looks for controllers in the "Controllers" folder and is named with the suffix "Controller". So if the first part of the URL is "Customer", MVC will look in the controllers folder for a class derived from System.Web.Mvc.Controller named "CustomerController".

The second part of the URL identifies an action. The action is a method within the controller that returns a System.Web.Mvc.ActionResult. The ActionResult identifies the view used to render a response (more on that in a later article). So if the second part of the URL is "Edit", MVC will look for a method in the controller class named "Edit" that returns an ActionResult.

The third part of the above URL defines a parameter for the action, in this case a parameter named "id".

The following URL

/Customer/Edit/2

causes MVC to search for a class named Controllers\CustomerController, to call the Edit method in this class and to pass the value 2 to the id parameter of the Edit method.

What if the URL does not contain all three parts? The Default route above specifies a default value for each of the parts. If the third part of the URL is omitted, no parameter is passed to the Action. For a URL with no id parameter, we will need to create an action method that does not expect a parameter. If the second part of the URL is omitted, the default action is "Index", so MVC will look for a method named "Index" in the controller class. If the first part of the URL is omitted, it defaults to "Home" so MVC will look for a Controller class named "HomeController" in the Controllers folder.

You can use this same syntax to add more routes to your application. Simply add more calls to routes.MapRoute() in Global.asax. MVC will match URLs to these routes in the order listed.

Notice that the RouteTable and RouteCollection are part of the System.Web.Routing namespace and not part of any MVC namespace. This should tell you that the routing engine is not restricted to MVC applications. It can be used in any ASP.NET application if you want cleaner URLs.

If you find a URL like /Customer/Edit/2 more asthetically pleasing than /Customers/EditCustomer.aspx?CustID=2, you should investigate the routing engine.

Microsoft first released ASP.NET almost eight years ago. At that time, they created a model they hoped would be familiar (and compelling) to Windows forms developers, particularly to those working in Visual Basic 6.

ASP.NET adopted a development paradigm that mimicked Windows forms. This programming model was referred to as “web forms” and it abstracted away much of the complexity of HTML and HTTP, easing the transition from Windows to the web for many developers. Using web forms, developers could drag controls, such as buttons and textboxes, onto a design surface and add code that ran automatically when a user interacted with a control – such as when a user clicks a button. Pages and controls had events, such as Load and Init that ran at specified times during a page’s creation. By default, each page had a code-behind file – class containing code that responded to page events. These concepts were familiar to Visual Basic developers and this helped to drive adoption of ASP.NET.

But there are some drawbacks to this model. Web forms abstracted away the details of HTML and HTTP, but this abstraction cost the developer control over the rendering of pages and controls. Some developers felt that the web forms framework got in the way of their web developing by hiding these basic constructs. Also, tying code to web form events made it difficult to test much of the application. Testing frameworks evolved that would mimic the behavior of a web server, just to integrate with automated unit testing frameworks.

Recently Microsoft released ASP.NET MVC - a new programming framework designed to build web applications with HTML and HTTP. This framework uses the Model-View-Controller pattern.

The Model-View-Controller pattern is not new. However the release of ASP.NET MVC (I’ll refer to it as "MVC" going forward) has renewed interest in this pattern.

MVC consists of three main parts. You’ll never guess what they are. Give up? They are the Model, the View and the Controller.

The Model contains the application’s data and any business rules associated with that data. It is up to the Model to retrieve and update data from and to a database (or other persistent data store or back-end), to validate that data and to apply any business rules to that data.

The View is a template for the user interface. It should contain no logic at all. In fact, in the ASP.NET MVC framework, by default View web pages don’t even have a code-behind file. A view in this framework consists only of HTML mixed with some placeholders to output values from the model or helper functions based on those values.

The Controller is the glue that binds the Model to the View. By default, each web request in ASP.NET MVC gets routed to a given method (known as an “Action”) of a given class (known as a "Controller"). This method executes and returns either a view or enough information for the framework to identify and render a view.

MVC has two main advantages over web forms –It is easier to test and it gives more control to the developer.

Separating an application into three distinct parts makes it far easier to test. Launching a user interface in an automated testing framework, such as NUnit or MSTest is possible but it’s clumsy and slow. Minimizing the code in the user interface allows us to test the code more easily.

MVC also gives the developer more control over the rendered HTML (the view) than is possible in web forms. Web forms deliberately abstract away much of the HTML rendering, while MVC forces the developer to write explicit HTML in his View templates.

The release of ASP.NET MVC certainly does not signal the end of web forms. Many developers appreciate the abstraction that web forms provides for them. Many web forms still exist in production and I have yet to hear anyone refer to these as "legacy" applications or "Classic ASP.NET".

But for those who want more control over their output, a more pure separation of concerns and easier testability, ASP.NET MVC offers a good option.