ASP.NET MVC in Delphi Prism – Introduction

ASP.NET MVC is a web development framework from Microsoft that combines the effectiveness of the model-view-controller architecture .

It is an alternative to the WebForms that was and is still mostly used one in ASP.NET .

What is a Model View Controller (MVC) Framework?

MVC is a framework methodology that divides an application into 3 components: models,views, and controllers.

  • Models are responsible for maintaining state. This can be be the database access methods etc.
  • Views are responsible for displaying the application’s user interface.
  • Controllers are responsible for handling end user interaction, manipulating the model, and selecting a view to render to display UI.

Requirements to build the ASP.NET MVC Application

Note : I will be using Delphi prism 2010 to demonstrate . Delphi prism is based on the Oxygene language and compiler, integrated within the Microsoft Visual Studio. It is one of the fast way to build .NET, ASP.NET, data-driven and cross-platform Mono applications .

For more details visit :

Creating a New ASP.NET MVC Project

To create a new ASP.NET MVC project, open Visual Studio and go to File ->New ->Project.

Make sure the framework selector reads .NET Framework 3.5, and select ASP.NET MVC Web Application, as shown below . Set the Project name and click ok .


Visual Studio will now set up a default project structure for you.Press F5 ,Immediately we see something working.


Visual studio by default creates the user login and the Registration module too .we can delete them and make necessary changes if required so that we can start fresh .


ASP.NET MVC Project Folders

  • Models — Contains model classes.
  • Views — Contains ASP.NET MVC views .
  • Controllers —Contains controller classes.
  • Scripts — Contains JavaScript and JQuery Files .
  • Content — Contains files like CSS etc.
  • App_Data — Contains any database files that needs to be included in the Application.

How it works ?

In ASP.NET MVC, controllers are just simple classes (Delphi / C# ) derived from System.Web.Mvc.Controller .

The public methods in a controller class is the action method, which can be invoked via URL.


HomeController =
{ Methods }
publicmethod About: ActionResult;
method _Index: ActionResult;
HomeController.About: ActionResult;
result := View
HomeController._Index: ActionResult;
ViewData[‘Message’] := ‘Welcome to Senthil Kumar’s ASP.NET MVC App’;
result := View
In the above sourcecode sample , About and _Index are action methods.

The routing system, decides how URLs map onto particular controllers and actions .When a new Application is created , the default URL is configured .
This can be specified in the Global.asax file too.

Example :
Global_asax =publicclass(System.Web.HttpApplication)
method RegisterRoutes(routes : RouteCollection);
method Application_Start(sender: object; e: EventArgs);
Global_Asax.Application_Start(sender: object; e: EventArgs);
Global_asax.RegisterRoutes(routes: RouteCollection);
routes.MapRoute(“Default”, // Route name
“{controller}/{action}/{id}”, // URL with parameters
newclass (controller := ‘Home’, action := ‘ViewPage1’, id := ) // Parameter defaults);
When an MVC application starts, the Application_Start() method is called. This method,calls the RegisterRoutes() method. The RegisterRoutes() method creates the route table.

As you can see the MapRoute method , here the 1st part is the Controller name ({Controller}) ,2nd part is the controller action method ({action}) and 3rd segment id the id .if you don’t supply an id, the id parameter defaults to an empty string.

In the above example , if the URL Path is
/HomeController/_Index/ it goes to the page _Index .

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.


  1. Bushnell Legend 8×32 Roof Prism Binoculars Review « The Best Digital Camera and Binoculars Reviews April 1, 2010 Reply
  2. QWMichael April 19, 2010 Reply
  3. Emily April 23, 2010 Reply
  4. Astrid August 26, 2010 Reply
  5. ASP.NET MVC in Delphi Prism – Introduction | ProgramInDotnet August 7, 2011 Reply

Leave a Reply


Interesting BlogPosts to read

Passing Array of Integers to ASP.NET Web API REST Service
You can pass an array of integer to an ASP.NET Web Web API REST service by setting the [FromUri] att...
Dealing with the column names that looks like SQL Keywords in SQL Server
There are times when you might have a column names in your SQL Server database table that might look...
SQL Server's ISNULL() equivalent in PostgreSQL
SQL Server provides an function ISNULL if the value placed in the 2nd parameter if the first paramet...