Add status code response capabilities to PrerenderTagHelper and RenderToStringResult. Client can now send status codes back based on client routes.

This commit is contained in:
peterlazzarino
2017-02-21 22:04:31 -05:00
committed by Steve Sanderson
parent b9c387bf5f
commit 347524a116
3 changed files with 11 additions and 0 deletions

View File

@@ -129,6 +129,11 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
return;
}
if (result.StatusCode.HasValue)
{
ViewContext.HttpContext.Response.StatusCode = result.StatusCode.Value;
}
// It's some HTML to inject
output.Content.SetHtmlContent(result.Html);

View File

@@ -25,5 +25,10 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// to the SPA's routing configuration.
/// </summary>
public string RedirectUrl { get; set; }
/// <summary>
/// If set, specifies the HTTP status code that should be sent back with the server response.
/// </summary>
public int? StatusCode { get; set; }
}
}

View File

@@ -8,6 +8,7 @@ interface RenderToStringCallback {
interface RenderToStringResult {
html: string;
statusCode: number;
globals?: { [key: string]: any };
}