2. Agenda
2
Introduction
Choosing between webform & MVC
How MVC Work?
Creating Model
Creating Controller
Creating View
Advantages
Disadvantages
3. Introduction
MVC is one of three ASP.NET
Programming Model.
MVC stands for Model View Controller-
the names of the three major
components of this style of application
Development
Model
View
Controller
3
4. Introduction
Model refers to a data model,which is something
that you can use to perform create
,read,update,delete(CRUD) operation on your
application data.
View is what is present to user.[Display Data]
Controllers are code file that bridge between
views and models.It read data from view,control
user input and send input data to the model
4
5. Choosing between MVC & WebForm
MVC is not replacing WebForms. Both these
development models exist and can be used to
develop ASP.NET applications.MVC Web Form
MVC is a lightweight and follow
MVC (Model, View, Controller)
pattern based development
model.
follows a traditional event driven
development model.
follow customizable syntax (Razor
as default)
follows Web Forms Syntax.
In MVC, Views and logic are kept
separately.
In Asp.Net Web Form, Web
Forms(ASPX) i.e. views are tightly
coupled to Code
behind(ASPX.CS) i.e. logic.
MVC has Layouts for consistent Web Form has Master Pages for5
11. Creating Model
DataModel.emdx :-
This XML file defines the
schema for your data model
DataModel.Designer.cs:-
This is C# code file
containing
the mapping object of your data model.
11
12. Creating Controller
Controller process requests and determine which
view should be returned to the client.
Ex:
public ActionResult Index()
{
Db_MVC db=new Db_MVC();
return view(db.user);
}
12
13. Creating view
Right click any where in code for the contoller
index
method ,and select add view option
13
14. Advantages of MVC
SoC – Separation of Concerns
Separation of Concern is one of the core
advantages of ASP.NET MVC . The MVC
framework provides a clean separation of the UI
, Business Logic , Model or Data.
More Control
The ASP.NET MVC framework provides more
control over the HTML , JavaScript and CSS
than the traditional Web Forms.
14
15. Advantages of MVC
Testability
ASP.NET MVC framework provides better
testability of the Web Application and good
support for the test driven development too.
Lightweight
ASP.NET MVC framework doesn’t use View
State and thus reduces the bandwidth of the
requests to an extent.
15
16. Advantages of MVC
Full features of ASP.NET
One of the key advantages of using ASP.NET
MVC is that it is built on top of ASP.NET
framework and hence most of the features of the
ASP.NET like membership providers , roles etc
can still be used.
16
17. Disadvantages of MVC
17
HTML & CSS skills must be revive
MVC requires the developer to understand how
the client-side code and HTML all play together
MVC is still "relatively" new