Hello Everyone,
Umbraco.UIBuilder: 17.0.5
When using FileActionResult in a UI Builder action, the file download works correctly on success. However, if an exception occurs while executing the action, the error notification is not displayed on the UI Builder frontend.
The action fails server-side and returns a failed FileActionResult with an ActionNotification, but no error message is shown to the user in the backoffice UI.
This makes it difficult for editors to understand why the action failed.
Steps to Reproduce
-
Create a UI Builder action that inherits from Action
-
Return a successful FileActionResult on success
-
Throw an exception or return a failed FileActionResult with an error notification
-
Trigger the action from the UI Builder toolbar
Expected Behaviour
When an exception occurs, the error notification provided in FileActionResult should be displayed in the UI Builder frontend.
Please find example codebase as below:
using System.Text;
using Microsoft.Extensions.Logging;
using Umbraco.UIBuilder.Configuration.Actions;
namespace Demo.UIBuilder.Actions
{
public class DemoDownloadFile
: Action<FileActionResult>
{
private readonly ILogger<DemoDownloadFile> _logger;
public DemoDownloadFile(ILogger<DemoDownloadFile> logger)
{
_logger = logger;
}
public override string Alias => "demoDownloadFile";
public override string Name => "Demo Download File";
public override FileActionResult Execute(string collectionAlias, object[] entityIds)
{
try
{
var content = "UI Builder download demo file";
var bytes = Encoding.UTF8.GetBytes(content);
var stream = new MemoryStream(bytes);
stream.Position = 0;
return new FileActionResult(
true,
fileStream: stream,
fileType: "text/plain",
fileName: "ui-builder-demo.txt",
new ActionNotification("Success", "Download triggered")
);
}
catch (Exception ex)
{
_logger.LogError(ex, "Demo download failed");
return new(
false,
new ActionNotification("Error", "Download failed")
);
}
}
}
}