mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Prerendering server-side code can now issue redirections. Fixes #280
This commit is contained in:
@@ -85,6 +85,15 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
unencodedPathAndQuery,
|
unencodedPathAndQuery,
|
||||||
CustomDataParameter,
|
CustomDataParameter,
|
||||||
TimeoutMillisecondsParameter);
|
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);
|
output.Content.SetHtmlContent(result.Html);
|
||||||
|
|
||||||
// Also attach any specified globals to the 'window' object. This is useful for transferring
|
// Also attach any specified globals to the 'window' object. This is useful for transferring
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
{
|
{
|
||||||
public JObject Globals { get; set; }
|
public JObject Globals { get; set; }
|
||||||
public string Html { get; set; }
|
public string Html { get; set; }
|
||||||
|
public string RedirectUrl { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user