What is ASP.net MVC ?
In this article, we will discuss the MVC framework but before that will discuss ASP.net.
ASP.net:
ASP.net is an open-source, server-side framework developed by Microsoft Corporation on January 5, 2002. Framework written in .NET languages is designed for web development to produce dynamic web pages. This framework supports the usage of HTML, CSS, and JavaScript. Web API’s can also be created using technologies like Web sockets.
ASP.net offers three types of frameworks for creating web applications:
1. Web forms:
Web forms are used to build simple web applications using a drag-and-drop, event-driven model. It offers many controls and other components that can be easily dragged with data accessibility.
2. ASP.net MVC:
MVC offers a pattern-based approach. This approach enables clear separation between the data model used, presented information, and control information. It is used to build heavy, complex websites.
3. ASP.net Web Pages:
ASP.net Web Pages enables combining server-side code with HTML, CSS in a lighter way. It allows the application to connect with databases, easily add videos, and link various social networking sites.
In this article we will only discuss ASP.net MVC in brief.
ASP.net MVC Introduction:
MVC stands for Model View Controller. It is an architectural pattern that is used by many languages with slight variations. But ASP.Net core MVC is among the best variation. It is a rich framework supported by ASP.net which is best suitable for building complex web applications and APIs
MVC stands for Model View Controller.
Here are the terms:
Model:
Model is the first Key component of this architectural framework. This component is only associated with the data of the application.
The model component represents the state of application and logic or operations to be performed. It encapsulates the operational logic and implementation logic to preserve the state of the application. In simpler words model is that component of any application that represents the state at which application resides with regards to program and also binds the logic behind the operation and logic behind the implementation of data altogether.
View:
The view represents the application’s data to the user.
View the component which is responsible for creating User Interface which presents the data of the application. Razor view engine is used in MVC to embed .NET code in HTML markup. View supports only that logic which is used to create user interface or to present the content. In order to use complex logic in view files to obtain data from the complex model developer can use view components,
Controller:
The controller is the 3rd component of the MVC model that handles the user interaction.
While the view is responsible for the user interface, controllers are responsible for handling the user’s activity and are responsible for user interaction. It executes the operations required whenever any event is triggered by the view or by any other external source. When the user raises an HTTP request, the controller addresses the request and handles it.
The controller is the decision-maker for selecting the model type and view.
Working:
MVC design pattern separates the application concerns in these three components. Although the View and controller work hand in hand, the model is not dependent on any of these so it is easy to build and test the model independent of presentation. In this diagram, one can see even though the model s independent but communicates with other components. Whenever the user requests something, the view will send the request to the controller, only the controller will communicate with the database. Then will forward the information to the model. The model will deal with logic and send it back to the view. As the view works behind the user interface, View will display the response to the user.