public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = ContentType; if (ResultDocument == null || ResultDocument.Root == null) { context.HttpContext.Response.Write(string.Empty); } else { ResultDocument.ToNullHelper().Branch( doc => doc.Save(context.HttpContext.Response.Output, SaveOptions.None), () => { /*if doc doesn't exist, does nothing*/ }); } }