MVC interduced in 1970s.
It actually splits the application to 3 main aspects (Model, View, Controller)
M in MVC: (Model)
Classes that describes the business logic and data, business rules for how the data can be changed and manipulated. It also handles the Data Access Layer. it can access by both view & controller
It can be split in diff layers
Responsible for transforming a model or models into UI. It gives UI for all validation and logic
it may use model to display data in page.
C in MVC: (Controller)
Responsible for controlling the application logic and acts as the coordinator between the View and the Model. It receive input from users via the View, Then process data in model and passing result back to view. It inherits system.mvc.controller
Apart from this, there must have a Global.asax file in root folder, and a web.config like a traditional ASP.NET application.
The specified URL will first get parsed via
So for [xyz.com]/home/index/:
There can be more than one action method, but MVC will only invoke the action method which has been parsed from the URL, its
So something like:
Invoking action method can return plain text string OR rendered HTML by using view.
Invoking view will return
In our case, controller was home and action was
It actually splits the application to 3 main aspects (Model, View, Controller)
M in MVC: (Model)
Classes that describes the business logic and data, business rules for how the data can be changed and manipulated. It also handles the Data Access Layer. it can access by both view & controller
It can be split in diff layers
- Data Access Layer : Access and manipulate the database of your application.
- Business Layer: Implement your business logic and validations for your application.
Responsible for transforming a model or models into UI. It gives UI for all validation and logic
it may use model to display data in page.
C in MVC: (Controller)
Responsible for controlling the application logic and acts as the coordinator between the View and the Model. It receive input from users via the View, Then process data in model and passing result back to view. It inherits system.mvc.controller
Apart from this, there must have a Global.asax file in root folder, and a web.config like a traditional ASP.NET application.
The specified URL will first get parsed via
application_start()
method inside Global.asax file. From the requested URL, it will parse the Controller, Action and ID.So for [xyz.com]/home/index/:
- Controller = home
- Action = index()
- ID = empty — we have not specified ID in [xyz.com]/home/index/, so it will consider as empty string
There can be more than one action method, but MVC will only invoke the action method which has been parsed from the URL, its
index()
in our case.So something like:
homeController.index()
will happen inside MVC controller class.Invoking action method can return plain text string OR rendered HTML by using view.
Invoking view will return
view()
. A call to view will
access the particular ASPX page inside the view directory and generate
the rendered HTML from the ASPX and will respond back to the browser.In our case, controller was home and action was
index()
. So calling view()
will return a rendered HTML from the ASPX page located at /views/home/index.aspx.
No comments:
Post a Comment