Represents a result that does nothing, such as a controller action method that returns nothing.
System.Web.Mvc.ActionResult
System.Web.Mvc.EmptyResult
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Public Class EmptyResult _ Inherits ActionResult
public class EmptyResult : ActionResult
public ref class EmptyResult : public ActionResult
The EmptyResult type exposes the following members.
| Name | Description | |
|---|---|---|
|
EmptyResult | Initializes a new instance of the EmptyResult class. |
| Name | Description | |
|---|---|---|
|
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
|
ExecuteResult | Executes the specified result context. (Overrides ActionResult.ExecuteResult(ControllerContext).) |
|
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
|
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
|
GetType | Gets the Type of the current instance. (Inherited from Object.) |
|
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
|
ToString | Returns a string that represents the current object. (Inherited from Object.) |
This class follows a pattern known as the Null Object pattern.
Reference
Other Resources
I mostly code WebForms and am new to MVC. When I first heard of this EmptyResult class, I was quite confused and I couldn't figure out why it was necessary. Then I searched StackOverflow (SO) and found these quality explanations:
http://stackoverflow.com/questions/5452172/mvc3-return-emptyresult-when-its-a-good-idea-to-return-this
http://stackoverflow.com/questions/8561038/return-new-emptyresult-vs-return-null
While the above SO threads are available (if necessary), it would also be useful if Microsoft or a member of the community posted a small code example showing an action that returns the EmptyResult.
Best,
Shawn