From my understanding there is some idea that the workflows should be able to be fired async (like in a new thread) there’s some setting for this in the co figs. Given this there workflows would not have any access to the current HttpRequest. While this is a concept it does not really work so I’ve always been running in “synchronous” mode.
In this mode you should have access to the HttpContext via HttpContext.Current, which maybe means that you could populate the request body or maybe set a redirect to your controller to serve the file.
This would depend on when in the pipeline the redirect from Forms is set.
No sorry, I can simply call that controller from the workflow, but stepping(debugging) through the controller code the file is never served, unlike the mock MVC project I build which indeed served the file.
Workflow -> Controller(simple standard MVC Controller)
Hmm, I'm not a 100% sure that I understand you, but let me try. It feels like we're talking about two things, both how to get the workflow to return a redirect to a controller and how to get the controller to serve a file.
As I understand:
You have another (non Umbraco project) where you have this controller and serving the files works, but you haven't manage to get this working with Umbraco?
What kind of controller are you trying to use? A "RenderMvcController"?
You could use a "regular" controller (inherit the standard mvc Controller-class) and route this.
Then, like I wrote, I'm not 100% sure that you can redirect from the workflow to this controller but it might be possible by setting up the HttpContext from your workflow.
"You have another (non Umbraco project) where you have this controller and serving the files works, but you haven't manage to get this working with Umbraco?"Yes
"What kind of controller are you trying to use? A "RenderMvcController"?"Yes
I have now got this to work, concept for anyone else that is doing something similar.
Workflow containing a 'RedirectToAction' (my method name) method that uses the System.Web.HttpContext,Current command, then serializes the object data and sends to ActionResult controller.
In the ActionResult controller which inherits a surface controller deserializes the object and uses your method to build your word document and return a File type.
I have a js code in the Form.cshtml file that presents a modal popup from bootstrap that allows the user to restart the umbraco form again with a simple redirect.
Export to Word, CSV file
I have posted elsewhere but no real answer; https://our.umbraco.com/forum/using-umbraco-and-getting-started/104532-workflowtype-output-word-document-to-client
Is it possible to serve up a word/csv file from the Umbraco Forms submission using a workflow?
At the moment I have the workflow call a controller and it steps through okay but never serves this to the client.
I have tested the functionality in a mock MVC project and are successful.
Can we do this in Umbraco?
Good and interesting question! :)
From my understanding there is some idea that the workflows should be able to be fired async (like in a new thread) there’s some setting for this in the co figs. Given this there workflows would not have any access to the current HttpRequest. While this is a concept it does not really work so I’ve always been running in “synchronous” mode.
In this mode you should have access to the HttpContext via HttpContext.Current, which maybe means that you could populate the request body or maybe set a redirect to your controller to serve the file.
This would depend on when in the pipeline the redirect from Forms is set.
Are you following what I’m thinking?
Hi Markus,
Thank you for getting back to me on this.
"HttpContext.Current, which maybe means that you could populate the request body or maybe set a redirect to your controller to serve the file."
So at this point in the workflow it is calling/redirecting to the controller to serve the file, but doesn't.
I tried introducing this to the controller:
I don't think I get it tbh...
Hi!
Are you saying that you've managed to perform a redirect to the controller from the workflow but that the file is not served?
Does the controller work when you hit it directly?
Hi,
No sorry, I can simply call that controller from the workflow, but stepping(debugging) through the controller code the file is never served, unlike the mock MVC project I build which indeed served the file.
Workflow -> Controller(simple standard MVC Controller)
Are you referring to doing this when calling controller; https://our.umbraco.com/Documentation/Reference/Routing/custom-controllers-v7
Hi!
Hmm, I'm not a 100% sure that I understand you, but let me try. It feels like we're talking about two things, both how to get the workflow to return a redirect to a controller and how to get the controller to serve a file.
As I understand:
You have another (non Umbraco project) where you have this controller and serving the files works, but you haven't manage to get this working with Umbraco?
What kind of controller are you trying to use? A "RenderMvcController"?
You could use a "regular" controller (inherit the standard mvc Controller-class) and route this.
https://our.umbraco.com/forum/using-umbraco-and-getting-started/101128-need-to-use-standard-mvc-controller
Then, like I wrote, I'm not 100% sure that you can redirect from the workflow to this controller but it might be possible by setting up the HttpContext from your workflow.
Hi,
Thank you for not giving up on me :-)
"You have another (non Umbraco project) where you have this controller and serving the files works, but you haven't manage to get this working with Umbraco?" Yes
"What kind of controller are you trying to use? A "RenderMvcController"?" Yes
"You could use a "regular" controller (inherit the standard mvc Controller-class) and route this. https://our.umbraco.com/forum/using-umbraco-and-getting-started/101128-need-to-use-standard-mvc-controller Then, like I wrote, I'm not 100% sure that you can redirect from the workflow to this controller but it might be possible by setting up the HttpContext from your workflow."
Thank you very much will give that a try..
I have now got this to work, concept for anyone else that is doing something similar.
Workflow containing a 'RedirectToAction' (my method name) method that uses the System.Web.HttpContext,Current command, then serializes the object data and sends to ActionResult controller.
In the ActionResult controller which inherits a surface controller deserializes the object and uses your method to build your word document and return a File type.
I have a js code in the Form.cshtml file that presents a modal popup from bootstrap that allows the user to restart the umbraco form again with a simple redirect.
Hope it helps someone out there.
is working on a reply...