-
Notifications
You must be signed in to change notification settings - Fork 927
Rendering without HTTPContext #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is because some classes are registered "per request": React.NET/src/React.AspNet.Middleware/ReactBuilderExtensions.cs Lines 65 to 80 in 5cbcd22
This means there's one singleton instance per request, and that instance is disposed at the end of the request. If there's no current request, this won't work, as we don't know the lifetime that the object should have. One potential solution I can think of is to update cc @dustinsoftware - What do you think of this? |
This is like #449, but for .NET Core, right? Maybe there is something similar to |
Thanks for the explanation Daniel15. Right coka it does look similar and I am running on .NET Core. |
I like this, let's keep this issue open until we add support for this. |
I'm closing issues for future tasks like this that aren't actively being worked on, but would be open to adding support for this! |
I'm able to generate the HTML from a react component with the following code when processing an Http request. However the initialization blows up when ran elsewhere. Is it possible to render a component to html without an HTTPContext?
var environment = ReactEnvironment.Current; var reactComponent = environment.CreateComponent(component, props); var html = reactComponent.RenderHtml(renderServerOnly: true);
The text was updated successfully, but these errors were encountered: