What is the best way to get error messages from a WF4 workflow back to a hosting ASP.NET MVC application? I need the workflow to not terminate, but continue to be active, and then pass a message back to the hosting app regarding the error, so the user can take an alternative action, but I'm not sure how to do that.
In order to keep your workflow alive you need to catch the exception in your workflow. Add a TryCatch activity to you workflow and in a Catch block you can use either a Send or a custom activity to send the data to the host application.
The one exception is to use the WorkflowApplication.OnUnhandledException with persistence and specify abort. In that case the in memory state of the workflow is just removed and the workflow can be reloaded for the last persisted state. If you go this way you need to make sure, using the Perist activity, that your workflow is saved whenever something that cannot be redone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With