ActionResult和ViewResult 区别

在做MVC示例的时候有了疑问,首先看stackoverflow上的解答:

ActionResult is an abstract class that can have several subtypes:

a) ViewResult - Renders a specifed view to the response stream

b) PartialViewResult - Renders a specifed partial view to the response stream

c) EmptyResult - An empty response is returned

d) RedirectResult - Performs an HTTP redirection to a specifed URL

e) RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data

f) JsonResult - Serializes a given ViewData object to JSON format

g) JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client

h) ContentResult - Writes content to the response stream without requiring a view

i) FileContentResult - Returns a fle to the client

j) FileStreamResult - Returns a fle to the client, which is provided by a Stream

k) FilePathResult - Returns a fle to the client

上面一段是说ActionResult 是抽象类,a~k列举了它的派生类。好吧,这张图片更清晰明了:

image

 

更详细的请看:http://weblogs.asp.net/rajbk/archive/2010/05/03/actionresult-types-in-mvc2.aspx

posted @ 2012-08-21 18:50  Stopwatch  阅读(631)  评论(1)    收藏  举报