at 01:08 AM
When it comes to application development within the Microsoft Stack, there are two popular frameworks: Asp.Net MVC and Web Forms. Asp.net was developed a few years ago as a replacement to Classic ASP, and it featured Web Forms.
However, while Web Forms was acceptable for smaller projects, proved to be difficult to scale for larger applications. Specific pages and code tend to be tightly tied together and the heavy reliance on the server to handle events, control rendering also adds to reduced performance. Asp.net MVC help alleviate these issues by implementing the “Model View Controller” pattern. With the separation of the layers, it helps development by allowing applications to be more expandable, quicker to develop and more organized long term when it comes to maintenance.
One of the first steps when converting a non MVC asp.net site to ASP.net MVC site, is to define your Model, View, Controller architecture.
Starting with the Model layer, this begins with identifying the data elements used by the application. These data objects would be retrieved by the controller layer and used in order to generate the view which is returned back to the user’s browser. During this step additional layers to work with the database are created. This approach allows more flexibility in case of changes in the database. In general this can be done by analyzing the existing database and in most cases each table can be represented as a data model object.
The Controller layer, is responsible for managing user interactions with the application, by responding to user request and returning the appropriate updates are made to the user’s view (browser). At this step we would analyze all the pages of the previous application and determine all actions, events that are required. This includes preparing data to be displayed on page load, responding to button clicks whether saving data, page navigation etc.
Through the separation of the code behind on each page, the View layer is now more free to be coded with more plain HTML code. This can be done through the Razor markup which presents a more html like way of embedding code or even updating the view to use a more front-end framework like Angular. During this step, web form pages will be stripped of the server side control code and focus on updating to contain only front end UI view code. This results in view pages that are easier to update based on designs from Graphic Designers who may not be as familiar with working with or have direct access to the asp.net web form code.