ViewResult Class

 

Represents a class that is used to render a view by using an IView instance that is returned by an IViewEngine object.

Namespace:   System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Inheritance Hierarchy

System.Object
  System.Web.Mvc.ActionResult
    System.Web.Mvc.ViewResultBase
      System.Web.Mvc.ViewResult

Syntax

public class ViewResult : ViewResultBase
public ref class ViewResult : ViewResultBase
type ViewResult = 
    class
        inherit ViewResultBase
    end
Public Class ViewResult
    Inherits ViewResultBase

Constructors

Name Description
System_CAPS_pubmethod ViewResult()

Initializes a new instance of the ViewResult class.

Properties

Name Description
System_CAPS_pubproperty MasterName

Gets the name of the master view (such as a master page or template) to use when the view is rendered.

System_CAPS_pubproperty Model

Gets the view data model.(Inherited from ViewResultBase.)

System_CAPS_pubproperty TempData

Gets or sets the TempDataDictionary object for this result.(Inherited from ViewResultBase.)

System_CAPS_pubproperty View

Gets or sets the IView object that is rendered to the response.(Inherited from ViewResultBase.)

System_CAPS_pubproperty ViewBag

Gets the view bag.(Inherited from ViewResultBase.)

System_CAPS_pubproperty ViewData

Gets or sets the view data ViewDataDictionary object for this result.(Inherited from ViewResultBase.)

System_CAPS_pubproperty ViewEngineCollection

Gets or sets the collection of view engines that are associated with this result.(Inherited from ViewResultBase.)

System_CAPS_pubproperty ViewName

Gets or sets the name of the view to render.(Inherited from ViewResultBase.)

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod ExecuteResult(ControllerContext)

When called by the action invoker, renders the view to the response.(Inherited from ViewResultBase.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_protmethod FindView(ControllerContext)

Searches the registered view engines and returns the object that is used to render the view.(Overrides ViewResultBase.FindView(ControllerContext).)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

An action result represents a command that ASP.NET performs on behalf of an action method. The ViewResult class implements the abstract ViewResultBase class and is used to render a view. This class contains methods for finding the view to render and for executing the result. This class also contains properties that identify the view to render, the name of the view, the name of the master view, view data, temporary data, and a collection for view engines for the application.

If you want an action method to result in a rendered view, the action method should return a call to the controller's View helper method. The View helper method passes a ViewResult object to the ASP.NET MVC framework, which calls the object's ExecuteResult method.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

System.Web.Mvc Namespace

Return to top