Request interrupted for ReturnFileAsync

Trying to use the Return File Async
MemoryStream ms = new MemoryStream(ExportDataBytes)
{
Position = 0
};
await Context.ReturnFileAsync(ms, “ConfirmationTracking.csv”, “text/csv”).ConfigureAwait(false);
from
<dot:Button Click=“{command: ExportGridData(exportData)}” Text=“Export” ButtonTagName=“input”/>
Dotvvm version
Keep getting this error on the await line in C#:
DotVVM.Framework.Hosting.DotvvmInterruptRequestExecutionException: ‘Request interrupted: ReturnFile (ConfirmationTracking.csv)’

The file is getting created in the temp directory as per
options.AddDefaultTempStorages(“temp”);

What Am I missing?

That means your the file should be successfully returned (instead of the standard HTTP response). The exception is just a way to terminate the request processing; it’s a common pitfall, but we don’t really have another way of doing that.

No file downloads. Thoughts?

You should avoid handling this exception, it should be left to propagate back to DotVVM.

Can you please inspect the network communication, what response is returned from the postback? (just see devtools Network tab). Are there any messages in client-side log or the server-side log?

[NullReferenceException: Object reference not set to an instance of an object.]
DotVVM.Framework.Storage.d__12.MoveNext() in //src/Framework/Framework/Storage/FileSystemReturnedFileStorage.cs:80
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
System.Runtime.CompilerServices.ConfiguredTaskAwaiter.GetResult() +38
d__22.MoveNext() in /
/src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs:268
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
System.Runtime.CompilerServices.ConfiguredTaskAwaiter.GetResult() +29
VeritasMVC.ViewModels.AllFiles.BankruptcyReports.d__7.MoveNext() +3528
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action) +114

Just got it working, thanks for your help!

Great! What helped in the end?

I added too much code that interferred, so i simplified it. Also my VS is set to break on all faults. Never saw where i could continue and then it worked. Do you have any examples of custom form editor? thanks.

1 Like