Search code examples
javascript.netasp.net-mvcreactjsserverside-javascript

React.js C# server side rendering *without* ASP.NET MVC


I use my own .NET web server and would like to pre-render web pages which are build on React.js. I was seaking a way to do it, but the only way I found is to use helper methods for ASP's Rasor renderer.

Is there a good known way to render React.js DOM as string with pure C#?


Solution

  • Daniel Lo Nigro was kind to provide details how to do it with React.NET

    var environment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>(); 
    var component = environment.CreateComponent("HelloWorld", new { name = "Daniel" });
    var html = component.RenderHtml();
    

    More details https://github.com/reactjs/React.NET/issues/178