Output template offered only as download - not displayed as HTML page

Hi everyone!

I have a strange phenomenon on one of the IS with which I’m working.
I use HTML-pages and output templates for invoking services on the IS. A sketch of the situation:

Package: xyz
In the pub/ directory of the package I have an index.html file.
In that HTML file I offer the possibility to upload a file. The uploaded file is processed by the flow service processReceivedHttpData defined in the package xyz.
The HTML code of the form in index.html looks more or less like this:

<form action="/invoke/xyz/processReceivedHttpData" 
         enctype="multipart/form-data" method="post">
<input name="xmldata" type="file" size="60">
<input type="submit" value="Import">

In the service processReceivedHttpData I set an output template (at design time). I edited the template so that it returns some information about the process.

If I open the index.html and upload the file, the processReceivedHttpData service is executed. I expect an HTML-page as result - from the output template. However, the web-browser does not display an HTML-page, but offers a file for download, after submitting the form. The offered file is, interestingly enough, the HTML-page which should be displayed as the result. If I save it and offer it in a webbrowser it is displayed as expected!

What could be wrong here?

I solved the issue by inserting pub.report:runTemplateOnPipe and pub.flow:setResponse, where I explicitly apply the template that I previously set at design time as output template for the service.
I should be happy that we found this way for solving the issue, however, I’d like to know about the reasons for not getting the response-page displayed in the browser.

I would be pleased if someone could give me hints.


I would imagine that it might be something to do with the content-type your index.html is passing to the service. It must be overriding the content-type of the output template, which should be text/html (or something like that)
That would explain why browser is trying to download instead.
Try saving the pipeline in the service and clear pipeline at the end except for the data you need. As last resort, setting the proper content-type using setResponse should resolve it.