Prerendering server-side code can now issue redirections. Fixes #280

This commit is contained in:
SteveSandersonMS
2016-09-09 11:09:44 +01:00
parent c2c45b04df
commit 1be9102aea
2 changed files with 10 additions and 0 deletions

View File

@@ -85,6 +85,15 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
unencodedPathAndQuery,
CustomDataParameter,
TimeoutMillisecondsParameter);
if (!string.IsNullOrEmpty(result.RedirectUrl))
{
// It's a redirection
ViewContext.HttpContext.Response.Redirect(result.RedirectUrl);
return;
}
// It's some HTML to inject
output.Content.SetHtmlContent(result.Html);
// Also attach any specified globals to the 'window' object. This is useful for transferring

View File

@@ -6,5 +6,6 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
{
public JObject Globals { get; set; }
public string Html { get; set; }
public string RedirectUrl { get; set; }
}
}