This project is read-only.

Web Request Workflow Activity

Topics: Customizing Orchard
Feb 20, 2015 at 10:59 PM
Edited Feb 20, 2015 at 10:59 PM
I couldn't find any tutorials on how to use the Web Request activity. I have a route and a controller that I would like to send a web request to upon submission of a specific form. I have a workflow set up that sends the request along with the form data to my route which calls my controller's action. I would then like the controller to run some math on the form data provided and return a string containing html instead of a view. The first problem lies in getting the controller to return a string instead of a view as it doesn't match the return type and then accessing that string. I am trying to prevent a page load from happening. I would like to have the workflow make the request to the controller, when the form is submitted, and have the controller return the result and then display the result on the same page as the form. Therein lies my second problem as I have no inkling of how to return a response to the get request and then access that response. Ideally I would be able to have my controller return the response instead of a view and the response would be a string of html which can then be displayed on the same page as the form. Another problem with this is whether or not there is a way to inject the response into the dom without javascript. Thank you.
Feb 21, 2015 at 9:25 AM
First problem: You can return a ContentResult from your controller's action method.
Second problem: You either need to return the entire HTML if the page (with your string response embedded somewhere in that output), or use AJAX to inject the response where you need it to be.
Marked as answer by emeraldarcher on 2/23/2015 at 10:38 AM
Feb 23, 2015 at 6:08 PM
Edited Feb 23, 2015 at 6:15 PM
Thank you sfmskywalker for responding. I tried returning a ContentResult and it worked beautifully. I even was able to render the returned html string with the notify activity which works perfectly except that it appends a bunch of <br> tags to my content. It's weird because the <br> tags are appended within my outermost <div> tag but before any of my actual content. I tried stepping through the code and watching the html string as it moved around but never saw the <br> tags get added. It must be happening between the notify activity and the render by the notifier service. Any ideas? Thank you.

Edit: I wonder if the problem may be that the notifier converts the string to a localizedString...
Feb 23, 2015 at 6:38 PM
Sorry, I figured out the problem. The html string was built with Environment.NewLine between each tag which was causing the <br> tags to be created. I just removed all of these and it appears to be working now.