Add status code support to SpaPrerenderingExtensions
This commit is contained in:
parent
f9c62ebb5a
commit
8ded472fe9
|
|
@ -225,7 +225,8 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(renderResult.RedirectUrl))
|
if (!string.IsNullOrEmpty(renderResult.RedirectUrl))
|
||||||
{
|
{
|
||||||
context.Response.Redirect(renderResult.RedirectUrl);
|
var permanentRedirect = renderResult.StatusCode.GetValueOrDefault() == 301;
|
||||||
|
context.Response.Redirect(renderResult.RedirectUrl, permanentRedirect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -239,6 +240,11 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
$"embed any information you wish to return to the client.");
|
$"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";
|
context.Response.ContentType = "text/html";
|
||||||
await context.Response.WriteAsync(renderResult.Html);
|
await context.Response.WriteAsync(renderResult.Html);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue