return new EmptyResult() VS return NULL

You can return null. MVC will detect that and return an EmptyResult.

MSDN: EmptyResult represents a result that doesn't do anything, like a controller action returning null

Source code of MVC.

public class EmptyResult : ActionResult {

    private static readonly EmptyResult _singleton = new EmptyResult();

    internal static EmptyResult Instance {
        get {
            return _singleton;
        }
    }

    public override void ExecuteResult(ControllerContext context) {
    }
}

And the source from ControllerActionInvoker which shows if you return null, MVC will return EmptyResult.

protected virtual ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue) {
    if (actionReturnValue == null) {
        return new EmptyResult();
    }

    ActionResult actionResult = (actionReturnValue as ActionResult) ??
        new ContentResult { Content = Convert.ToString(actionReturnValue, CultureInfo.InvariantCulture) };
    return actionResult;
}

You can download the source code of the Asp.Net MVC Project on Codeplex.


When you return null from an action the MVC framework (actually the ControllerActionInvoker class) will internally create a new EmptyResult. So finally an instance of the EmptyResult class will be used in both cases. So there is no real difference.

In my personal opinion return new EmptyResult() is better because it communicates more clearly that your action returns nothing.