-
Notifications
You must be signed in to change notification settings - Fork 1
/
HomeController.cs
87 lines (80 loc) · 3.22 KB
/
HomeController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SSR.Net.Services;
namespace SSR.Net.DotNet6.Controllers {
public class HomeController : Controller {
private readonly React17Renderer _react17Renderer;
private readonly React18Renderer _react18Renderer;
private readonly Vue3Renderer _vue3Renderer;
public HomeController(React17Renderer react17Renderer,
React18Renderer react18Renderer,
Vue3Renderer vue3Renderer) {
_react17Renderer = react17Renderer;
_react18Renderer = react18Renderer;
_vue3Renderer = vue3Renderer;
}
public ActionResult Index() => View();
public ActionResult React17() {
var propsJson = JsonConvert.SerializeObject(
new {
header = "React 17 with SSR",
links = new[]{
new {
text = "Google.com",
href ="https://www.google.com"
},
new {
text = "Hacker news",
href = "https://news.ycombinator.org"
}
}
});
var renderedComponent = _react17Renderer.RenderComponent("Components.FrontPage", propsJson);
return base.View(renderedComponent);
}
public ActionResult React18() {
var propsJson = JsonConvert.SerializeObject(
new {
header = "React 18 with SSR",
links = new[]{
new {
text = "Google.com",
href = "https://www.google.com"
},
new {
text = "Hacker news",
href = "https://news.ycombinator.org"
}
}
});
var renderedComponent = _react18Renderer.RenderComponent("Components.FrontPage", propsJson);
return View(renderedComponent);
}
public ActionResult React19() {
var propsJson = JsonConvert.SerializeObject(
new {
header = "React 19 with SSR",
links = new[]{
new {
text = "Google.com",
href = "https://www.google.com"
},
new {
text = "Hacker news",
href = "https://news.ycombinator.org"
}
}
});
var renderedComponent = _react18Renderer.RenderComponent("Components.FrontPage", propsJson);
return View(renderedComponent);
}
public ActionResult Vue3() {
var propsJson = JsonConvert.SerializeObject(
new {
title = "Vue 3 with SSR"
});
var renderedComponent = _vue3Renderer.RenderComponent("Components.Example", propsJson);
return View(renderedComponent);
}
}
}