Atozed Forums

Full Version: After SendFile Exception GotoURL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My case:

Define IWServerControllerBaseConfig

with THandlers.Add('', 'main', TContentForm.Create(TMainForm)) do
  begin
    CanStartSession := true;
    RequiresSessionStart := false;
end;

with THandlers.Add('', 'help', TContentForm.Create(THelpForm)) do
  begin
    CanStartSession := true;
    RequiresSessionStart := false;
end;

I have in HelpForm Download Button for my PDF.

procedure DownloadButtonClick(Sender: TObject) ;
begin
     WebApplication.SendFile('My.pdf', true, '','');
     WebApplication.GotoURL('/main');
end;

OnClick -> ERROR Exception error raised, with message : Reply type already set.
You can't redirect after SendFile(). SendFile() is a download and the browser won't respond to any other content (javascript or html) afterwards