SlideShare a Scribd company logo
2
Most read
S.No ActionResult() ViewResult()
1 What is ActionResult() ?
ActionResult() is a general result type that
can have several subtypes.
ActionResult() is an abstract class.
ActionResult() is a base class for
ViewResult()
In MVC framework, it uses ActionResult
class to reference the object our action
method returns. And invokes ExecuteResult
method on it.
What is ViewResult() ?
ViewResult() renders a specifed view to the
response stream.
ViewResult() is a concrete class.
ViewResult() is a derived class of
ActionResult()
ViewResult is an implementation for this
abstract class (ActionResult class). It will try
to find a view page (usually aspx page) in
some predefined
paths(/views/controllername/, /views/shared/,
etc) by the given view name.
2 What are the subtypes of ActionResult
class?
. ViewResult - Renders a specifed view
to the response stream
• PartialViewResult - Renders a
specifed partial view to the response
stream
• EmptyResult - An empty response
is returned
• RedirectResult - Performs an HTTP
redirection to a specifed URL
• RedirectToRouteResult - Performs
an HTTP redirection to a URL that is
determined by the routing engine,
based on given route data
• JsonResult - Serializes a given
ViewData object to JSON format
• JavaScriptResult - Returns a piece
of JavaScript code that can be
executed on the client
• ContentResult - Writes content to
the response stream without
requiring a view
• FileContentResult - Returns a file
to the client
• FileStreamResult - Returns a file to
the client, which is provided by a
Stream
What are the subtypes of ViewResult class?
As it is a concrete class, so subtypes are not
available for ViewResult class.
• FilePathResult - Returns a file to
the client
3 Example:
(OR)
"ActionResult" can be used to exploit
polymorphism and dynamism. So if we are
returning different types of view
dynamically "ActionResult" is the best
thing. For example in the above code
snippet we can see we have a simple action
called as "DynamicView". Depending on
the flag ("IsHtmlView") it will either return
"ViewResult" or "JsonResult".
Example:
4 When to go for ActionResult class ?
If our action method may have different
behavior, like either render a view or
perform a redirection. We can use the more
general base class ActionResult as the return
type.
When to go for ViewResult class ?
If we are sure that our action method will
return some view page, we can use
ViewResult.
Reference:
http://onlydifferencefaqs.blogspot.in/2014/03/difference-between-actionresult-and.html

More Related Content

PPTX
ASP.NET MVC Presentation
PPT
JDBC
PPTX
Implicit objects advance Java
PPT
Switch statements in Java
PDF
SOAP-based Web Services
PPT
ASP .net MVC
PPTX
OOP Introduction with java programming language
PPT
Java Networking
ASP.NET MVC Presentation
JDBC
Implicit objects advance Java
Switch statements in Java
SOAP-based Web Services
ASP .net MVC
OOP Introduction with java programming language
Java Networking

What's hot (20)

PPTX
Ch 7 data binding
PPSX
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
PPT
Corba introduction and simple example
PPTX
ASP.NET Web API
PPTX
JSON and XML
PPTX
Express JS
PPT
PPT
Applet life cycle
PDF
Java Programming
PPTX
Asp objects
PPT
ADO .Net
PDF
Oracle to MySQL DatabaseLink
PPSX
JDBC: java DataBase connectivity
PPT
Looping statements in Java
PPT
Java 8 Streams
PPTX
Getting started with entity framework
PPTX
Spring Framework
PPT
Spring AOP
PPT
Java servlets
Ch 7 data binding
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Corba introduction and simple example
ASP.NET Web API
JSON and XML
Express JS
Applet life cycle
Java Programming
Asp objects
ADO .Net
Oracle to MySQL DatabaseLink
JDBC: java DataBase connectivity
Looping statements in Java
Java 8 Streams
Getting started with entity framework
Spring Framework
Spring AOP
Java servlets
Ad

Similar to Difference between ActionResult() and ViewResult() (20)

PDF
Murach: How to transfer data from controllers
PPTX
Controller
PPTX
L09 Frameworks
PPT
Object Oriented Programming In .Net
PPTX
A brief overview of java frameworks
PDF
.NET Core, ASP.NET Core Course, Session 11
PDF
C# Advanced L07-Design Patterns
PPTX
Chapter4.pptx
PPTX
L05 Frameworks
PPTX
Structural pattern 3
PDF
Skroutz Android MVP and Adapter Delegates presentation
PDF
Spring MVC
PDF
Design patterns
PPT
Jedi slides 2.1 object-oriented concepts
PDF
Mvc interview questions – deep dive jinal desai
PPTX
Controllers & actions
PDF
ThingMaker in Swift
PPT
Ruby On Rails
PPTX
Java J2EE Interview Questions Part 2
PPTX
Java J2EE Interview Question Part 2
Murach: How to transfer data from controllers
Controller
L09 Frameworks
Object Oriented Programming In .Net
A brief overview of java frameworks
.NET Core, ASP.NET Core Course, Session 11
C# Advanced L07-Design Patterns
Chapter4.pptx
L05 Frameworks
Structural pattern 3
Skroutz Android MVP and Adapter Delegates presentation
Spring MVC
Design patterns
Jedi slides 2.1 object-oriented concepts
Mvc interview questions – deep dive jinal desai
Controllers & actions
ThingMaker in Swift
Ruby On Rails
Java J2EE Interview Questions Part 2
Java J2EE Interview Question Part 2
Ad

More from Umar Ali (20)

PDF
Difference between wcf and asp.net web api
PDF
Difference between asp.net mvc 3 and asp.net mvc 4
PDF
Difference between asp.net web api and asp.net mvc
PDF
Difference between asp.net web forms and asp.net mvc
PDF
ASP.NET MVC difference between questions list 1
ODT
Link checkers 1
PDF
Affiliate Networks Sites-1
PDF
Technical Video Training Sites- 1
PDF
US News Sites- 1
PDF
How to create user friendly file hosting link sites
PDF
Weak hadiths in tamil
PDF
Bulughul Maram in tamil
PDF
Asp.net website usage and job trends
PDF
Indian news sites- 1
PDF
Photo sharing sites- 1
PDF
File hosting search engines
PDF
Ajax difference faqs compiled- 1
PDF
ADO.NET difference faqs compiled- 1
PDF
Dotnet differences compiled -1
PDF
.NET Differences List
Difference between wcf and asp.net web api
Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net web api and asp.net mvc
Difference between asp.net web forms and asp.net mvc
ASP.NET MVC difference between questions list 1
Link checkers 1
Affiliate Networks Sites-1
Technical Video Training Sites- 1
US News Sites- 1
How to create user friendly file hosting link sites
Weak hadiths in tamil
Bulughul Maram in tamil
Asp.net website usage and job trends
Indian news sites- 1
Photo sharing sites- 1
File hosting search engines
Ajax difference faqs compiled- 1
ADO.NET difference faqs compiled- 1
Dotnet differences compiled -1
.NET Differences List

Recently uploaded (20)

PPTX
cloud_computing_Infrastucture_as_cloud_p
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
August Patch Tuesday
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
cloud_computing_Infrastucture_as_cloud_p
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
NewMind AI Weekly Chronicles - August'25-Week II
August Patch Tuesday
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectroscopy.pptx food analysis technology
SOPHOS-XG Firewall Administrator PPT.pptx

Difference between ActionResult() and ViewResult()

  • 1. S.No ActionResult() ViewResult() 1 What is ActionResult() ? ActionResult() is a general result type that can have several subtypes. ActionResult() is an abstract class. ActionResult() is a base class for ViewResult() In MVC framework, it uses ActionResult class to reference the object our action method returns. And invokes ExecuteResult method on it. What is ViewResult() ? ViewResult() renders a specifed view to the response stream. ViewResult() is a concrete class. ViewResult() is a derived class of ActionResult() ViewResult is an implementation for this abstract class (ActionResult class). It will try to find a view page (usually aspx page) in some predefined paths(/views/controllername/, /views/shared/, etc) by the given view name. 2 What are the subtypes of ActionResult class? . ViewResult - Renders a specifed view to the response stream • PartialViewResult - Renders a specifed partial view to the response stream • EmptyResult - An empty response is returned • RedirectResult - Performs an HTTP redirection to a specifed URL • RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data • JsonResult - Serializes a given ViewData object to JSON format • JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client • ContentResult - Writes content to the response stream without requiring a view • FileContentResult - Returns a file to the client • FileStreamResult - Returns a file to the client, which is provided by a Stream What are the subtypes of ViewResult class? As it is a concrete class, so subtypes are not available for ViewResult class.
  • 2. • FilePathResult - Returns a file to the client 3 Example: (OR) "ActionResult" can be used to exploit polymorphism and dynamism. So if we are returning different types of view dynamically "ActionResult" is the best thing. For example in the above code snippet we can see we have a simple action called as "DynamicView". Depending on the flag ("IsHtmlView") it will either return "ViewResult" or "JsonResult". Example: 4 When to go for ActionResult class ? If our action method may have different behavior, like either render a view or perform a redirection. We can use the more general base class ActionResult as the return type. When to go for ViewResult class ? If we are sure that our action method will return some view page, we can use ViewResult. Reference: http://onlydifferencefaqs.blogspot.in/2014/03/difference-between-actionresult-and.html