Skip to content

Commit

Permalink
Fix redirect behavior
Browse files Browse the repository at this point in the history
Fixes #459
  • Loading branch information
sfmskywalker committed Nov 13, 2020
1 parent 55d176a commit 5cdcb75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/activities/Elsa.Activities.Http/Activities/Redirect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public bool Permanent

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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/activities/Elsa.Activities.Http/WorkflowHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace Elsa.Activities.Http
{
public class WorkflowHttpResult
{
public static readonly WorkflowHttpResult Instance = new WorkflowHttpResult();
public static readonly WorkflowHttpResult Instance = new();
}
}

0 comments on commit 5cdcb75

Please sign in to comment.