Professional Documents
Culture Documents
MVC :
If we want transfer from back end to front end we use view back.
2.Advantages of MVC
- Loosely coupled
- Light weight
- Re usabilty
- More understandable
1.Creating the request - Request object creation has four major parts
a.Fill route:
MVC request are mapped to route tables which specifiies which controller and action
to be invoked.
So first thing is to fill out the route table with route collection. Filling of
route table happens in
global.asax file.
b.Fetch Route
Depending on the URL sent "URLRoutingModule" search the route table to create
"RouteData" object which has the details of
which controller and action to invoke.
This has two steps - Executing the action and sending the results to the view
Total there are 9 returns type which return results from controller to view.
5.ContentType: this result type is used to retun any httpContent like text /plain
as the result of action
6.JSON Result: this return type is used when we want to return any json messages
7.Javascript result: this return type is used when we want to return the java
script that returns in the browser
8.File results: this can be used when we want to send binary output in response.
9.empty reslut: this return type is used when we return nothing (void ) in the
result
5. Filters in MVC
In MVC controller defince action method, usually these action methods generally
have a one to one relationship with UI controls such as clikcing button or link.
But many times, we would like perfom some action before and after some operation.
For achieving this functionality, MVC provides feature called filters.
Types of Filter:
1.Action Filters: Action filters are used to implemnet logic that gets executed
before and after control action executes.
4.Exception Filter: this filter is used to handle errors raised by either your
control actions or control action methods
6.Routing in MVC
Routing is mechanisum that process incomming URL and give the desired response.
1.Convention based routing: To define this type of routing, we call MapRoute method
and set its unique name, URL pattern and specify some default values
2.Attribute based routing: in this method, we specify the route attribute in the
action method of controller
1.Controller Name
2.Action Method name
3.Parameter
1.View Data - It is used to pass data from controller to view, It requires type
casting for large data and check for null value to avoid error
2.View Bag
3.Temp Data