This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Allow custom values from JS to be returned from renderToString in SpaServices #384
Closed
Description
I think a useful feature would be to allow values other than the rendered html to be passed back from the renderToString JavaScript context to the .NET world. For example, the JS might provide a page title, which could then be rendered by the razor layout page. I think the ViewBag would be a good place for this data sharing.
For example, in boot-server.tsx
resolve({
html: renderToString(app),
globals: { initialReduxState: store.getState() },
viewBag: {
title: pageTitle
}
});
And in _Layout.cshtml
<html>
<head>
<title>@ViewBag.title</title>
Keen for thoughts and comments.
Metadata
Metadata
Assignees
Labels
No labels