Introduction
This article does an overview of Action Result return type
in MVC. I will be discussing about the various derived types of Action Result
abstract class which helps to return result in several ways and when will be
used what type of derived action result type with an examples.
Background
MVC stands for Model-View-Controller. It's a way of designing an application that
separates data access, business logic and the graphical user interface. The
goal is to make the application more maintainable.
In Brief, It can be described as follows:
Model: It represents
the core business logic and data
View: The view is
only responsible for representing the GUI by transforming a model(s).
Controller: It controls
the application logic and also it provides the coordination between the view
and models.
The communication between Controller to View to return any
data, model, file and view etc will be performed through the Action Result
abstract class as a return type.
About Action Result
The controller you can create an action method that returns such
as an integer or string or any object type. These return types can be
maintained in an appropriate way by defining ActionResult as return type. There
are many derived Action Result types in MVC that may use to return the results
from controller method to view.
Those are:
FileResult
|
RedirectResult
|
HttpStatusCodeResult
|
|
FileContentResult
|
RedirectToRouteResult
|
HttpUnAuthorizedResult
|
|
FilePathResult
|
JavaScriptResult
|
HttpNotFoundResult
|
|
ContentResult
|
FileStreamResult
|
EmptyResult
|
the message of all your blog is very interesting and you learn a lot. Thanks for the help you demonstrate on every page of your blog. Thank you thank you
ReplyDeleteVery clear concept you explained very well thanks for the post.
ReplyDelete