Right Money Management App For Your Financial Goals
Asp.net c# MVC-5 Training-Day-1 of Day-9
1. AHM Pervej Kabir
Analyst Programmer
pervej_kabir@yahoo.com
Cell:+8801757051005 Day-1: 06 September 2017
ASP.Net C#- MVC-5 Training
2. Introduction
About MVC
Routing Example
Logic Layer
View Engine
Request Response Process
Entity framework-EF Example
3. About Model –Viewer- Controller (MVC)
What is MVC?
MVC stand for Model-Viewer-Controller
It is software architectural pattern
o An architectural pattern is a general, reusable solution of a commonly occurring problem in
software architecture within the given context.
o Architectural pattern is similar to software design pattern but have a broader scope.
It divided an application’s implementation in three components (Model, Viewer and controller)
The Model represent the application core (for instance a list of database records)
The view displays the data (the database records)
The controller handles the input.
4. Model –Viewer- Controller (MVC) Design Goal
Separation of Concern
“The process of breaking a computer program into distinct features in functionality as little as possible “-
Wikipedia
Responsibility of Model, viewer & controller are separate
Embrace the web
Able to adopt the standard web technology HTML, CSS, CSS3 etc.
Run on Asp.Net
Run on top of Asp.Net run time
Extensible
Use different plugins and changes as you like
Testable
MVC design to allow loosely couple & solid object oriented concept
Any solution & code designed in the fashion is testable
5. MVC Logic Layer
MVC Provides full control over HTML, CSS and javascripts
You can think MVC Model defines web applications with 3 logic layers
o The business layer (Model logic)
o The display layer (Viewer logic)
o The input control (Controller logic)
The Model is the part of application that handles the logic for the application data
o Often Model objects retrieve data ( and store data ) from a database.
The View the part of application that display data
o Most often Views are created from the Model data.
The Controller is the part of application that user interaction
o Typically The Controller read data from the view, control user inputs and inputs data to the
model.
The MVC separation helps to manage complex applications because you can focus on one aspect of a time.
o For example, you can focus on the view without depending on the business logic .
o It all makes essayer to test an application
The MVC separation also simplifies group development
o Different developers can work on the view, the controller logic and the business logic in parallel.
.
6. What is view engine?
The view engines are responsible for rendering the HTML from views to the browser.
The view engines template will have different syntax for implementation.
Currently few number of view engines are available for Asp.net-MVC and top four are RAZOR, Traditional
ASPX, SPARK and Nhaml.
MVC Request and Response Process
ASP.Net MVC Request response process step by step following bellow-
1) User send the request by the URL
2) UrlRoutingModule intercepts /cut offs the request and starts parsing it.
3) The appropriate controller and handler will be identified from the URL by looking at the routing table
collection. Also any data coming alone with the request is kept in RouteData.
4) The appropriate action in the identified controller will be executed.
5) The action will call the model class based on data
6) The action will then pass to some view and tell the view to proceed
7) Now the view will execute and create the markup based on logic and model’s data then push the
HTML back to the browser