Different type of result in mvc :-
Note: It’s difficult to remember all the 12 types. But some important ones you can remember for the interview areActionResult
,ViewResult
, andJsonResult
. Below is a detailed list for your interest:
There 12 kinds of results in MVC, at the top is theActionResult
class which is a base class that can have 11 subtypes as listed below:
ViewResult
- Renders a specified view to the response streamPartialViewResult
- Renders a specified partial view to the response streamEmptyResult
- An empty response is returnedRedirectResult
- Performs an HTTP redirection to a specified URLRedirectToRouteResult
- Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route dataJsonResult
- Serializes a givenViewData
object to JSON formatJavaScriptResult
- Returns a piece of JavaScript code that can be executed on the clientContentResult
- Writes content to the response stream without requiring a viewFileContentResult
- Returns a file to the clientFileStreamResult
- Returns a file to the client, which is provided by aStream
FilePathResult
- Returns a file to the client