Kiwi MVC.NET : Building the application Part1

In this part, I am going to explain you how to setup an MVC .Net application.

I will tell you often “I am not a senior .Net developer”, I assume that I can make some faults and have totally wrong. If you think I am, do not hesitate to contact me at pierre@dervalp.com or leave me a comment in this blog. I would enjoy discussing with you. I am open-mind and I know I am far to know everything in software development. This blog would pretend to help people like me to find their way to make a MVC application using TDD and implement some well-known patterns.

1.       Configuration

Before you can start building websites with ASP.NET MVC, you need to install the following free software:

  • .NET Framework version 3.5 with Service Pack 1
  • Visual Web Developer 2008 Express with Service Pack 1
  • ASP.NET MVC 1.0

You can also download the Microsoft Webforms installer 2.0 beta which is a nice tool.

2.       What is MVC Framework

Microsoft is certainly better than me to explain this, so here is what they say:

ASP.NET MVC is a free and fully supported Microsoft framework for building web applications that use a model-view-controller pattern. Like ASP.NET Web Forms, ASP.NET MVC is built on the ASP.NET framework.

ASP.NET MVC provides the following benefits:

  • Clear separation of concerns
  • Testability – support for Test-Driven Development
  • Fine-grained control over HTML and JavaScript
  • Intuitive URLs

If you would like to know more in the pattern model-view-controller, I invite you to read these links (if you have others interesting link, please contact me and I will edit this post):

-          http://en.wikipedia.org/wiki/Model-view-controller

-          http://msdn.microsoft.com/en-us/library/ms978748.aspx

kiwi1-1

3.       Hey oh let’s go!

I know I will not work under source control, we will see that later if I needed.

First step, Start you visual studio 2008, File -> new -> Project

You receive this tab:

-          I decided to call my CMS Kiwi because it sounds sunny and funny.

Name: Kiwi.MVC.web. I would take a pseudo naming convention for this project. I do not know if it is the better but if it does not fit in the future, we’ll change it but I do not think it is the most important thing for the moment.

Location: Personally, I work with an external hard drive where I put my sources. As I do not work in source control, I take a back-up every day and I send it to my Gmail. I know it’s a bit dirty…

kiwi1-2

So, I create the project and VS pops up a window about creating a Unit Test Project:

This project will receive all my unit tests during the development

I change the name to /*My project name*/.MVC.Tests and let’s go…

kiwi1-3

4.       The Service project and the data project

I know what I am going to do is not the best way but I feel comfortable with that.

I add a new class library called Kiwi.MVC.Data to receive my model and another called Kiwi.MVC.Services who will receive my services.

I clean a bit and here is the result:

kiwi1-4

Before saving the solution, I would like to set up the behavior of VS. I want that VS stratup the project I am currently working on and not Kiwi.MVC.Web as it is by default. To do that, right click on your solution, properties and you receive that screen:

kiwi1-5

In the Startup Project, use Current selection in place of Single startup project.

I try to build the solution and if it builds successfully, I have now an empty project ready to go…

You can find the source of the empty project in Codeplex : here http://dervalp.codeplex.com

I am waiting for your feedback…

5.      My opinion about MVC:

“I have never like the webforms style of ASP.NET and this MVC framework is like a breath of fresh air for me. I used MVC pattern with Cakephp and I am very exited to discover all the possibilities of the ASP.NET MVC framework. I guess Microsoft is taking the right way to build powerfull web application while complying best practises.”

3 Responses to “Kiwi MVC.NET : Building the application Part1”

  1. In general your post is short and simple to follow. I like that fact you state that you don’t know it all. To me, one of the many things that makes a good developer, is admitting that you don’t know it all and being open minded.

    Good post.

  2. Do you use VWD or VS?

    In 1. Configuration – you sort of give me an impression that you’ll be using VWD. Then while creating the project it looks like VS (test project pop-up window).

    Anyhow this post is about MVC; went trough it and should agree – well done.

  3. I am using Visual Studio 2008 sp1

Leave a Reply