What are the different action method’s return type?

1) ViewResult : Used to return a view to render html in the browser. this is the most common used action result

2)PartialViewResult: Similar to view result, it returns a partial view.

3) ContentResult: Used to return any type of content. By default it is used to return plain text but the actual content type can be explicitly defined

4) EmptyResult: this is equivalent to void method,it is by definition an action result object,but it does nothing.

5)FileResult:Used to return binary content.

6)HttpUnauthroizedResult: You can return an HttpUnauthrized result when the request tries to access restricted content that, for example its not available to anonymous user.

7)JavaScriptResult:Used to  return JavaScript code.

8)JsonResult: Used  to return any object in JavaScript Object Notation(JSON) format.

9)RedirectRresult:Used to perform an HTTP redirect to another URL.you can define it as temporary (code 302) or permanent (code 301)  HTTP redirect.

10)RedirectToRouteResult: used to perform an HTTP redirect ,but to specific route rather than a URL

 

 

Leave a Reply