Add status code support to SpaPrerenderingExtensions

This commit is contained in:
Steve Sanderson
2017-12-12 12:28:31 +00:00
parent f9c62ebb5a
commit 8ded472fe9

View File

@@ -225,7 +225,8 @@ namespace Microsoft.AspNetCore.Builder
if (!string.IsNullOrEmpty(renderResult.RedirectUrl))
{
context.Response.Redirect(renderResult.RedirectUrl);
var permanentRedirect = renderResult.StatusCode.GetValueOrDefault() == 301;
context.Response.Redirect(renderResult.RedirectUrl, permanentRedirect);
}
else
{
@@ -239,6 +240,11 @@ namespace Microsoft.AspNetCore.Builder
$"embed any information you wish to return to the client.");
}
if (renderResult.StatusCode.HasValue)
{
context.Response.StatusCode = renderResult.StatusCode.Value;
}
context.Response.ContentType = "text/html";
await context.Response.WriteAsync(renderResult.Html);
}