Skip to content

Rendering without HTTPContext #600

@RAAAJohnson

Description

@RAAAJohnson

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);

System.NullReferenceException: Object reference not set to an instance of an object.
   at React.AspNet.HttpContextLifetimeProvider.get_Registrations()
   at React.AspNet.HttpContextLifetimeProvider.GetObject()
   at React.TinyIoC.TinyIoCContainer.CustomObjectLifetimeFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions