ActionResult extension doesn't work with Page() ActionResult method

This is an older question, but I needed functionality like this myself, and dug deep to find the reason.

As you can see from your debugging, the Page method generates a completely blank PageResult. Being as every property is null, calling ExecuteResultAsync on it fails as it obviously can't do anything with all-null values.

The reason Page() otherwise works the rest of the time is due to behind-the-scenes magic in PageActionInvoker, specifically in its InvokeResultAsync method. It will detect that your ViewData and Page are blank and populate them before it, itself, calls the pageResult.ExecuteResultAsync method.

Hence, you can still get your InformMessageResult to work if you do the same work as PageActionInvoker does. Here's how:

public override async Task ExecuteResultAsync(ActionContext context)
{
    /* temp data work goes here */

    if (InnerResult is PageResult pageResult)
    {
        var pageContext = context as PageContext
            ?? throw new ArgumentException("context must be a PageContext if your InnerResult is a PageResult.", "context");

        var pageFactoryProvider = pageContext.HttpContext.RequestServices.GetRequiredService<IPageFactoryProvider>();
        var pageFactory = pageFactoryProvider.CreatePageFactory(pageContext.ActionDescriptor);

        var viewContext = new ViewContext(
            pageContext,
            NullView.Instance,
            pageContext.ViewData,
            tempData,
            TextWriter.Null,
            new Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelperOptions()
        );
        viewContext.ExecutingFilePath = pageContext.ActionDescriptor.RelativePath;

        pageResult.ViewData = viewContext.ViewData;
        pageResult.Page = (PageBase)pageFactory(pageContext, viewContext);
    }

    await InnerResult.ExecuteResultAsync(context);
}

private class NullView : IView
{
    public static readonly NullView Instance = new NullView();

    public string Path => string.Empty;

    public Task RenderAsync(ViewContext context)
    {
        if (context == null) throw new ArgumentNullException("context");
        return Task.CompletedTask;
    }
}