SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Model View
Controller (MVC)
Group Members
 Muhammad Wajid (12-SE-01)
 Mubasher Hafeez (12-SE-07)
 Muhammad Ahsan (12-SE-53)
Introduction
 ASP.Net MVC is a framework for building web applications.
 Generally applies MVC Pattern on ASP.Net framework.
 Microsoft combines the effectiveness of model-view-controller.
Understanding the History of ASP.Net
 ASP.Net was a huge shift when it first arrived in 2002. Figure illustrate
Microsoft’s technology stacks as it appeared then.
Understanding ASP.Net Web Forms
 With Web Forms, Microsoft attempted to hide both HTTP and HTML by
modeling the user interface(UI) as a hierarchy of server side control
objects.
 Each control kept track of its own state across request, rendering itself as
HTML when needed and automatically connecting client-side events (for
example, a button click) with the corresponding server side event handler
code.
 Web Forms is a giant abstraction layer designed to deliver a classic event-
driven graphical user interface (FUI) over the web.
What to choose ?
Web Forms or MVC
 Two important factors you should consider while making the choice is :
 Rapid Application Development - If you want to develop anything rapidly
ASP.NET Web Forms is the only chance you are having, you can’t even
consider for ASP.NET MVC for RAD.
 Unit Testing - If automatic unit testing is most important factor for you
MVC will be best for you.
 Other than what you can do is, write down all your project requirement
and try to compare them with Pros and Cons of both Web Forms and MVC
The MVC Pattern
 The MVC separates the user interface (UI) into three main aspects:
 The Model : A set of classes that describes the data you’re working with.
 The View : Defines how to application’s UI will be displayed.
 The Controller : A set of classes that handles communication from the user.
An application specific logic.
Creating an ASP.Net MVC Application
 Begin with choosing File - > New Project as in figure :
Creating an ASP.Net MVC Application
contd

 Select Visual C# - > Web Template List then select ASP.Net MVC 4
Application, Name your application and click ok as in figure :
Creating an ASP.Net MVC Application
contd

 After creating a new MVC 4 application,
you’ll be presented with an
intermediate dialog with some MVC-specific
options for how the project should be
created, as shown .
 Select internet application from this dialog box
 select Razor View Engine
 and if you want unit testing
check the checkbox of
Create a unit test project and then click Ok.
MVC Application Structure
 When you create a new ASP.Net MVC application with Visual Studio, it
automatically adds some files and directories to the project as shown :
The Models
 When you create a new ASP.Net MVC template application project it
contains a folder named Model.
 Model folder usually contains files with extensions .cs .
 Model folder contains classes. You yourself specify classes according to
what is your working domain. for example
The Models contd

 The MVC Model contains all application logic.
 In MVC models both hold and manipulate application data.
Adding classes to Models
 In the Solution Explorer, right click the Models folder.
 Select Add and Select Class.
 Name the class and click ok.
 A new class will be added to Models folder.
Adding classes to Models contd...
The Controller’s Role
 Controller within the MVC pattern are responsible for responding to user
input.
 Controllers in the MVC pattern are concerned with the flow of the
application , working with data coming in, and providing data going out.
 With MVC the URL tells the routing mechanism which controller class to
instantiate and which action method to call, and supplies the required
arguments to that method
The Controller

 A Sample Code of
controller :
Creating New Controller
Creating New Controller
Writing Action Method
 Add as many Action Methods as you want:
 This is simple demonstration of writing Action Methods:
 When you create a new controller an index() Action Method already exist
with ActionResult signature change it to string to return a string and write
return “Hello from Store.Index();” as follows :
Accessing Action Methods
 Users interact with controllers and handle users input :
 When you run the project browser opens and have URL like
http://localhost 24461/ControllerName/ActionMethod/Parameter Value
 Type ControllerName and Action Method in it which user request the
controller respond accordingly
 http://localhost 24461/Store/detail/ and press enter
The Purpose of Views
 The View is responsible for providing the user interface (UI) to the user.
 The view transforms that model into a format ready to be presented to the
user.
 In ASP.Net MVC, the view accomplishes this by examining a model object
handed off to it by the controller and transforming the contents of that to
HTML.
 By convention the views directory contains a folder per controller. With the
same name as the controller.
Sample View Code
 This is an example of a sample view code :
ViewData and ViewBag
 These both are use to pass data from controller to view.
 Technically, data is passed from the controllers to the views via a
ViewDataDictionary called ViewData.
 ViewData Syntax as follows :
 ViewBag Syntax as follows :
Adding A View
 The easiest way to display the Add View dialog is to right-click in an action
method. As follows
Adding A View contd

 This bring up the Add View dialog,
as shown :
Partial View
 An action method can also return a partial view in the form of a
PartialViewResult via the PartialView method.
 The partial view itself looks much like a normal view, except it doesn’t
specify a layout.
 This is useful in partial update scenarios using AJAX.
Questions ???

Weitere Àhnliche Inhalte

Was ist angesagt?

ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Khaled Musaied
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
Sudhakar Sharma
 

Was ist angesagt? (20)

Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
MVC Architecture
MVC ArchitectureMVC Architecture
MVC Architecture
 
Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training session
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
 

Andere mochten auch

M5 l8-mvc-rails-handout
M5 l8-mvc-rails-handoutM5 l8-mvc-rails-handout
M5 l8-mvc-rails-handout
Nolboo Kim
 
Ds objects and models
Ds objects and modelsDs objects and models
Ds objects and models
Mayank Jain
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
Chamnap Chhorn
 

Andere mochten auch (14)

MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Message queuing telemetry transport (mqtt) launch
Message queuing telemetry transport (mqtt) launchMessage queuing telemetry transport (mqtt) launch
Message queuing telemetry transport (mqtt) launch
 
M5 l8-mvc-rails-handout
M5 l8-mvc-rails-handoutM5 l8-mvc-rails-handout
M5 l8-mvc-rails-handout
 
Message queuing telemetry transport (mqtt)
Message queuing telemetry transport (mqtt)Message queuing telemetry transport (mqtt)
Message queuing telemetry transport (mqtt)
 
Ds objects and models
Ds objects and modelsDs objects and models
Ds objects and models
 
An Introduction to the Message Queuing Technology & IBM WebSphere MQ
An Introduction to the Message Queuing Technology & IBM WebSphere MQAn Introduction to the Message Queuing Technology & IBM WebSphere MQ
An Introduction to the Message Queuing Technology & IBM WebSphere MQ
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Java RMI Presentation
Java RMI PresentationJava RMI Presentation
Java RMI Presentation
 
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 

Ähnlich wie Model view controller (mvc)

IntroductionToMVC
IntroductionToMVCIntroductionToMVC
IntroductionToMVC
Akhil Mittal
 
Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01
Jennie Gajjar
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 
ASP.NET MVC Introduction
ASP.NET MVC IntroductionASP.NET MVC Introduction
ASP.NET MVC Introduction
Sumit Chhabra
 
ASP.NET MVC Fundamental
ASP.NET MVC FundamentalASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ldcphuc
 

Ähnlich wie Model view controller (mvc) (20)

Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
MVC 4
MVC 4MVC 4
MVC 4
 
Intro ASP MVC
Intro ASP MVCIntro ASP MVC
Intro ASP MVC
 
IntroductionToMVC
IntroductionToMVCIntroductionToMVC
IntroductionToMVC
 
Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01
 
No brainer
No brainerNo brainer
No brainer
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Mvc
MvcMvc
Mvc
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJSIntroduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
 
ASP.NET MVC Introduction
ASP.NET MVC IntroductionASP.NET MVC Introduction
ASP.NET MVC Introduction
 
ASP.NET MVC Fundamental
ASP.NET MVC FundamentalASP.NET MVC Fundamental
ASP.NET MVC Fundamental
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9
 
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5  Building Your First Web Application (A Beginner S GuideASP.NET MVC 5  Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
 

KĂŒrzlich hochgeladen

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

KĂŒrzlich hochgeladen (20)

Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Model view controller (mvc)

  • 2. Group Members  Muhammad Wajid (12-SE-01)  Mubasher Hafeez (12-SE-07)  Muhammad Ahsan (12-SE-53)
  • 3. Introduction  ASP.Net MVC is a framework for building web applications.  Generally applies MVC Pattern on ASP.Net framework.  Microsoft combines the effectiveness of model-view-controller.
  • 4. Understanding the History of ASP.Net  ASP.Net was a huge shift when it first arrived in 2002. Figure illustrate Microsoft’s technology stacks as it appeared then.
  • 5. Understanding ASP.Net Web Forms  With Web Forms, Microsoft attempted to hide both HTTP and HTML by modeling the user interface(UI) as a hierarchy of server side control objects.  Each control kept track of its own state across request, rendering itself as HTML when needed and automatically connecting client-side events (for example, a button click) with the corresponding server side event handler code.  Web Forms is a giant abstraction layer designed to deliver a classic event- driven graphical user interface (FUI) over the web.
  • 6. What to choose ? Web Forms or MVC  Two important factors you should consider while making the choice is :  Rapid Application Development - If you want to develop anything rapidly ASP.NET Web Forms is the only chance you are having, you can’t even consider for ASP.NET MVC for RAD.  Unit Testing - If automatic unit testing is most important factor for you MVC will be best for you.  Other than what you can do is, write down all your project requirement and try to compare them with Pros and Cons of both Web Forms and MVC
  • 7. The MVC Pattern  The MVC separates the user interface (UI) into three main aspects:  The Model : A set of classes that describes the data you’re working with.  The View : Defines how to application’s UI will be displayed.  The Controller : A set of classes that handles communication from the user. An application specific logic.
  • 8. Creating an ASP.Net MVC Application  Begin with choosing File - > New Project as in figure :
  • 9. Creating an ASP.Net MVC Application contd
  Select Visual C# - > Web Template List then select ASP.Net MVC 4 Application, Name your application and click ok as in figure :
  • 10. Creating an ASP.Net MVC Application contd
  After creating a new MVC 4 application, you’ll be presented with an intermediate dialog with some MVC-specific options for how the project should be created, as shown .  Select internet application from this dialog box  select Razor View Engine  and if you want unit testing check the checkbox of Create a unit test project and then click Ok.
  • 11. MVC Application Structure  When you create a new ASP.Net MVC application with Visual Studio, it automatically adds some files and directories to the project as shown :
  • 12. The Models  When you create a new ASP.Net MVC template application project it contains a folder named Model.  Model folder usually contains files with extensions .cs .  Model folder contains classes. You yourself specify classes according to what is your working domain. for example
  • 13. The Models contd
  The MVC Model contains all application logic.  In MVC models both hold and manipulate application data.
  • 14. Adding classes to Models  In the Solution Explorer, right click the Models folder.  Select Add and Select Class.  Name the class and click ok.  A new class will be added to Models folder.
  • 15. Adding classes to Models contd...
  • 16. The Controller’s Role  Controller within the MVC pattern are responsible for responding to user input.  Controllers in the MVC pattern are concerned with the flow of the application , working with data coming in, and providing data going out.  With MVC the URL tells the routing mechanism which controller class to instantiate and which action method to call, and supplies the required arguments to that method
  • 17. The Controller
  A Sample Code of controller :
  • 20. Writing Action Method  Add as many Action Methods as you want:  This is simple demonstration of writing Action Methods:  When you create a new controller an index() Action Method already exist with ActionResult signature change it to string to return a string and write return “Hello from Store.Index();” as follows :
  • 21. Accessing Action Methods  Users interact with controllers and handle users input :  When you run the project browser opens and have URL like http://localhost 24461/ControllerName/ActionMethod/Parameter Value  Type ControllerName and Action Method in it which user request the controller respond accordingly  http://localhost 24461/Store/detail/ and press enter
  • 22. The Purpose of Views  The View is responsible for providing the user interface (UI) to the user.  The view transforms that model into a format ready to be presented to the user.  In ASP.Net MVC, the view accomplishes this by examining a model object handed off to it by the controller and transforming the contents of that to HTML.  By convention the views directory contains a folder per controller. With the same name as the controller.
  • 23. Sample View Code  This is an example of a sample view code :
  • 24. ViewData and ViewBag  These both are use to pass data from controller to view.  Technically, data is passed from the controllers to the views via a ViewDataDictionary called ViewData.  ViewData Syntax as follows :  ViewBag Syntax as follows :
  • 25. Adding A View  The easiest way to display the Add View dialog is to right-click in an action method. As follows
  • 26. Adding A View contd
  This bring up the Add View dialog, as shown :
  • 27. Partial View  An action method can also return a partial view in the form of a PartialViewResult via the PartialView method.  The partial view itself looks much like a normal view, except it doesn’t specify a layout.  This is useful in partial update scenarios using AJAX.