-
Notifications
You must be signed in to change notification settings - Fork 519
[Feature Request] - Add an SPA View Engine that gives the ability to render the entire page instead of using Razor #182
Comments
Great suggestion. Do you think it needs to be a view engine, or would a custom I added a sample in commit The example I've given isn't specific to React but the code you've posted above should work to perform the actual calls into React. You'd just need to wrap it in a promise as per the example here (this ensures that you can do async prerendering too if you need). What do you think? If more people ask for something like this, we could move |
👍 |
@SteveSandersonMS May be it reasonable to have something like a Middleware.
This is reasonable for apps that use ASPNET like a Advanced file server with some rest api feature, so any controllers and view is not really needed for them 😄 |
@laskoviymishka That sounds totally reasonable. If you can supply a proposed implementation and usage examples, we can definitely consider including some middleware like that! |
For example in React with Webpack, an entire page can be rendered with the Html React component looking something like this:
Html.js
Currently, it looks like the Razor view engine requires a layout and partial page.
It's possible to get around this somewhat by setting
IgnoreBody()
at the top of the _Layout and a placeholder view, but then you have to workaround the view by returningView("index", model)
every time._Layout.cshtml
Index.cshtml
Controller
The routing is handled by React Router.
This way works, but it seems like a lot of extra effort if a view engine could be created that could server the entire page, skipping Razor entirely.
The text was updated successfully, but these errors were encountered: