Asp.net Different Programming Models

Asp.net is a web development framework for building web pages and web application with HTML, Client side script, Server side script etc. There are 3 models provided by asp.net to build web application. Each model has different scope and application of use, so I am going to explain about each model.

1. Web Form

This is basically an event driven programming model which lets you build dynamic websites using familiar drag- and- drop. Design view and lot many controls helps you to develop application rapidly. This is a tradition approach to build website in asp.net. Web Forms are compiled and executed on the server, which generates the HTML that displays the web pages. This Model basically targets to those developers who prefer declarative and control based programming, such as Win Form etc. Developer does not require a lot of experience to develop application in this model. It is the most popular model of ASP.NET but has been criticized for the lack of control over the generated markup because a lot of abstractions are present in this model. In this model each page having aspx and .cs file. In aspx file we can write HTML tags, Server controls etc. and all events and code written in .cs file. So by maintaining two file this model separate code from front end tags for generating UI. There are following functionalities provided by this model.

  • Use page controller pattern means each page has a code behind class that act as a controller.
  • Code behind file depends on View so both will combine during execution.
  • There is lots of server controls provided, so it is very easy and fast development possible with this model.
  • Deep understanding of HTML, CSS and JavaScript is not required. With the basic knowledge of this you can start development in this model because all these things are abstract.
  • This Model provides Rapid development

2. Asp.net MVC

ASP.NET MVC is for developers who are interested in development like test-driven development, separation of concerns, inversion of control (IoC) etc. This framework separates the business logic layer of a web application from its presentation layer.

MVC is a framework for building web sites which uses MVC (Model View Controller) design:

  • The Model represents the behavior and data of application logic
  • The View displays the data and information
  • The Controller handles the input from user and create link between Model and View. Controller read data from a view and sends input data to the model.

MVC helps you manage complex applications, because you can focus on one aspect of an application at a time. For example, you can focus on the view without depending on the business logic. It also makes it easier to test an application. That's why test driven development is easy with MVC framework.

The MVC also facilitates the group development. Different developers can work on the view, the controller logic, and the business logic in parallel or if I want to explain in easy word then I can say developers can work on Model, View and controller separately and later on they can merge whole application.

The MVC programming model is a lighter alternative to ASP.NET Web Forms model. It is a lightweight, highly testable framework, integrated with all existing ASP.NET features, such as Master Pages, Authentication and Security.

This model uses Front Controller pattern. There is a single central controller for all pages to process web application. Developer should have good knowledge of HTML,CSS and Javascript in order to work with this model.

3. Web Pages

Web Pages are the easiest programming model for developing ASP.NET web pages. It provides an easy way to combine HTML, CSS, and JavaScript and server code. It uses Razor syntax to write server side and HTML. It is similar to PHP and classic ASP. In this page Model you can create HTML pages and then add server based code to page. It will be very easy to those developers who have worked on PHP and not having worked on ASP.NET before. There are following basic features of this model.

  • Easy to learn, understandand develop web application
  • Built aroundsingle web pages
  • Similar to PHPand Classic ASP pages
  • Server scriptingwith Visual Basic or C#
  • Full HTML, CSS,and JavaScript control