Fix redirect behavior

Fixes #459
This commit is contained in:
Sipke Schoorstra 2020-11-13 21:43:06 +01:00
parent 55d176a69b
commit 5cdcb75281
2 changed files with 4 additions and 2 deletions

View file

@ -40,13 +40,15 @@ namespace Elsa.Activities.Http.Activities
protected override async Task<ActivityExecutionResult> OnExecuteAsync(WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
{
var response = httpContextAccessor.HttpContext.Response;
var httpContext = httpContextAccessor.HttpContext;
var response = httpContext.Response;
if (response.HasStarted)
return Fault("Response has already started");
var location = await workflowContext.EvaluateAsync(Location, cancellationToken);
response.Redirect(location, Permanent);
httpContext.Items[WorkflowHttpResult.Instance] = WorkflowHttpResult.Instance;
return Done();
}

View file

@ -2,6 +2,6 @@ namespace Elsa.Activities.Http
{
public class WorkflowHttpResult
{
public static readonly WorkflowHttpResult Instance = new WorkflowHttpResult();
public static readonly WorkflowHttpResult Instance = new();
}
}