Skip to content

Commit d4adb16

Browse files
committed
Added brief guide for running ReactJS.NET in Azure.
1 parent 42d03ab commit d4adb16

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

site/jekyll/guides/azure.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
layout: docs
3+
title: Azure
4+
---
5+
6+
From **version 2.2.0** onwards ReactJS.NET works out of the box in Azure using the V8 JavaScript engine. Versions prior to 2.2.0 will fall back to using MSIE JavaScript engine and you may experience JavaScript errors during server-side rendering that you aren't experiencing locally.
7+
8+
You can run the following code to check which JavaScript engines are available on the machine that your application is running on. The engine with the lowest priority is used by ReactJS.NET.
9+
10+
```csharp
11+
public string GetAvailableEngines()
12+
{
13+
var sb = new StringBuilder();
14+
var registrations = React.TinyIoC.TinyIoCContainer.Current.ResolveAll<JavaScriptEngineFactory.Registration>();
15+
foreach (var registration in registrations.OrderBy(r => r.Priority))
16+
{
17+
try
18+
{
19+
var engine = registration.Factory();
20+
var result = engine.Evaluate<int>("1 + 1");
21+
if (result == 2)
22+
{
23+
sb.AppendLine($"Engine: {engine.Name}, version: {engine.Version}, priority: {registration.Priority}");
24+
}
25+
26+
}
27+
catch { }
28+
}
29+
30+
return sb.ToString();
31+
}
32+
```
33+
34+
To force ReactJS.NET to use the V8 JavaScript engine (and throw an exception if it isn't available) set the AllowMsieEngine configuration property to false.
35+
36+
```csharp
37+
app.UseReact(config =>
38+
{
39+
config
40+
// ..other configuration settings
41+
.SetAllowMsieEngine(false);
42+
});
43+
```

0 commit comments

Comments
 (0)