Skip to content

Add context.IncludeFileAsync to return file without terminating postback#2062

Open
exyi wants to merge 1 commit into
mainfrom
context-IncludeFile
Open

Add context.IncludeFileAsync to return file without terminating postback#2062
exyi wants to merge 1 commit into
mainfrom
context-IncludeFile

Conversation

@exyi

@exyi exyi commented Jun 29, 2026

Copy link
Copy Markdown
Member

Resolves #431

Implemementation is based on customProperties extension point instead of redirect

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a non-interrupting “return file” mechanism to DotVVM postbacks by storing returned-file metadata into customProperties and triggering the download client-side after the postback/static command completes, allowing the viewmodel to be updated first.

Changes:

  • Added IDotvvmRequestContext.IncludeReturnedFileAsync(...) to enqueue returned files into response customProperties without aborting the request.
  • Added client-side handling (handleIncludedReturnedFiles) to open/download included returned files after successful postbacks, static commands, and during initial page init.
  • Updated the ReturnedFile sample and Selenium tests to cover include-on-command/static-command/init scenarios.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs Adds IncludeReturnedFileAsync and refactors returned-file storage to support both interrupting and non-interrupting flows.
src/Framework/Framework/Resources/Scripts/postback/includedFiles.ts New helper to process _dotvvm_IncludedReturnedFiles in customProperties and trigger downloads/navigation.
src/Framework/Framework/Resources/Scripts/postback/postbackCore.ts Invokes included-file handling on successful postback responses and updates the TS response shape to customProperties.
src/Framework/Framework/Resources/Scripts/postback/staticCommand.ts Invokes included-file handling for static command responses.
src/Framework/Framework/Resources/Scripts/dotvvm-base.ts Invokes included-file handling on initial page init to support include-on-init.
src/Framework/Framework/Resources/Scripts/utils/magic-navigator.ts Extends navigator utility to support target/rel for opening inline files in a new tab safely.
src/Framework/Framework/Resources/Scripts/global-declarations.ts Updates client type declarations from customData to customProperties.
src/Samples/Common/ViewModels/FeatureSamples/ReturnedFile/ReturnedFileSampleViewModel.cs Adds sample commands/static command/init demonstrating included returned files and counters.
src/Samples/Common/Views/FeatureSamples/ReturnedFile/ReturnedFileSample.dothtml Adds UI for include-file scenarios and a static-command button.
src/Samples/Tests/Tests/Feature/ReturnedFileTests.cs Adds/updates UI tests validating include-file behavior across postback/static command/init.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs Outdated
Comment thread src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs Outdated
Comment thread src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs Outdated
Comment thread src/Framework/Framework/Hosting/DotvvmRequestContextExtensions.cs Outdated
Comment thread src/Framework/Framework/Resources/Scripts/postback/includedFiles.ts
Resolves #431

Implemementation is based on customProperties extension point instead of
redirect
@exyi
exyi force-pushed the context-IncludeFile branch from 4d9fb11 to 40f17e8 Compare July 10, 2026 09:12
@tomasherceg

Copy link
Copy Markdown
Member

Could we create and remove the fakeAnchor instead of keeping it there all the time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to redirect or return file after the successful postback

3 participants