Hello.
Ive been trying to use the nuget package React.AspNet in order to use react in a plugin.
However, im not able to register react as needed in startup. I ran the app in debug mode and i know the startup file is being run.
React has to be added before .UseMvc() and UseStaticFiles but how can i achive that? Is order 900 wrong?
This is my current starup:
public class PluginDbStartup : INopStartup
{
/// <summary>
/// Add and configure any of the middleware
/// </summary>
/// <param name="services">Collection of service descriptors</param>
/// <param name="configuration">Configuration root of the application</param>
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddReact();
}
/// <summary>
/// Configure the using of added middleware
/// </summary>
/// <param name="application">Builder for configuring an application's request pipeline</param>
public void Configure(IApplicationBuilder application)
{
application.UseReact(config=>
{
config
.AddScript("~/js/app.jsx")
.SetJsonSerializerSettings(new JsonSerializerSettings
{
StringEscapeHandling = StringEscapeHandling.EscapeHtml,
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
});
}
/// <summary>
/// Gets order of this startup configuration implementation
/// </summary>
public int Order => 900;
}
Error:
ReactJS.NET has not been initialised correctly. Please ensure you have called services.AddReact() and app.UseReact() in your Startup.cs file