Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, 5 August 2014

Action result types one of the common question in interview

ActionResult is an abstract class so you can never return it. You always return a derived class such as ViewResult, RedirectResult, JsonResult, FileResult, JavaScriptResult, ContentResult depending on what do you want your controller action to do (render a view, redirect to another url, return JSON formatted data, download a file, ...). As far as the signature of your action method is concerned I would recommend you always having ActionResult as return type.



ViewResult (View) --Renders a view as a Web page.

PartialViewResult  (PartialView)--Renders a partial view,which defines a section 

of view that can be rendered inside another view.

RedirectResult (Redirect)--Redirects to another action method by using its URL.


RedirectToRouteResult (RedirectToAction/RedirectToRoute)--Redirects to another action method.


ContentResult (Content)--Returns a user-defined 

content type.

JsonResult (Json)--Returns a serialized 

JSON object.

JavaScriptResult (JavaScript)--Returns a script that can

Be executed on the client.

FileResult (File)--Returns binary output to

 write to the response.


EmptyResult(None)--Represents a return value
that is used if the action
 method must return a
 null result (void).



No comments:

Post a Comment