Home > Articles > Programming > ASP .NET

Get Started Using ASP.NET MVC for Your .NET Applications

📄 Contents

  1. Get Started Using ASP.NET MVC for Your .NET Applications
  2. WebConfig.xml / Global.asax
  3. Home Controller / Home View
  • Print
  • + Share This
Programming expert Jesse Smith shows you the easy way to get started with the popular ASP.NET MVC framework. Learn how to build a simple "Hello World" application with ASP.NET MVC in only a few steps.
Like this article? We recommend

Like this article? We recommend

ASP.NET MVC (AMVC) is a lightweight, powerful and flexible framework for building .NET applications. It is easy to use and integrates nicely with the .NET frameworks. The AMVC framework for .NET contains everything you need for building .NET enterprise applications.

The MVC architecture is a popular choice among many development shops. It took awhile for .NET to start using the MVC architecture, but better late than never. .NET is very similar to the Ruby framework using MVC. As with Ruby, AMVC splits your application into Models, Views and Controllers. For every Model (i.e., Customer), there is a corresponding Controller with the same name. The Controller contains all the actions for the Model (i.e., add, remove etc.). Each Action in the controller has a corresponding view (i.e., CustomerAdd.aspx, CustomerRemove.aspx). Of course, you can change this convention, but this approach keeps everything "tight" maintenance-wise, while having all your application's layers totally decoupled. Almost every development framework for web-based applications has conformed to or now includes a way to implement the MVC architecture.

Simple Hello World

I'll take you on a short tour to set up a very simple AMVC application. In this example, I'll be using Visual Studio 2008 and AMVC 2. If you're using Visual Studio 2010, you can add AMVC 3 in exactly the same way. All the steps that follow are the same for both (the only difference is step 1, where you download either AMVC 2 or 3, depending on what which version of Visual Studio you're using (i.e. 2008, or 2010). To get started, follow the steps below:

  1. Download the AMVC framework from the Microsoft website.
  2. Open (or reopen) Visual Studio to register the AMVC project templates.
  3. Generate scaffolding by using the default project template for an AMVC application.

    If you've ever programmed in Ruby on Rails, you'll find AMVC is similar in a lot of ways. Like with Ruby, you can automate the scaffolding needed to organize your applications directory structure and basic setup. AMVC does this through the AMVC Web Application template. This AMVC template sets up a simple Home Controller.

  4. Once you define a new project using the AMVC Web Application template, you'll notice AMVC creates a Home Controller, along with HomeViews. Also included are an Account Controller, Model, and View for registering a new user on the site. To view the default site, simply press the F5 key and it will pop up in your default browser using a preassigned port.

And that's it! Talk about simple-you can build a basic AMVC application in only minutes. Let's go through what AMVC set up for us and why.

  • + Share This
  • 🔖 Save To Your Account