-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeController.cs
More file actions
97 lines (90 loc) · 3.46 KB
/
Copy pathHomeController.cs
File metadata and controls
97 lines (90 loc) · 3.46 KB
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
88
89
90
91
92
93
94
95
96
97
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SSR.Net.Services;
namespace SSR.Net.DotNet10.Controllers
{
public class HomeController : Controller
{
private readonly React17Renderer _react17Renderer;
private readonly React18Renderer _react18Renderer;
private readonly React19Renderer _react19Renderer;
private readonly Vue3Renderer _vue3Renderer;
public HomeController(React17Renderer react17Renderer,
React18Renderer react18Renderer,
React19Renderer react19Renderer,
Vue3Renderer vue3Renderer)
{
_react17Renderer = react17Renderer;
_react18Renderer = react18Renderer;
_react19Renderer = react19Renderer;
_vue3Renderer = vue3Renderer;
}
public ActionResult Index() => View();
public ActionResult React17()
{
var propsJson = JsonConvert.SerializeObject(
new {
header = "React 17 with SSR",
links = new[]{
new {
text = "Firefox",
href = "https://www.firefox.com/"
},
new {
text = "Hacker news",
href = "https://news.ycombinator.com"
}
}
});
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 = "Firefox",
href = "https://www.firefox.com/"
},
new {
text = "Hacker news",
href = "https://news.ycombinator.com"
}
}
});
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 = "Firefox",
href = "https://www.firefox.com/"
},
new {
text = "Hacker news",
href = "https://news.ycombinator.com"
}
}
});
var renderedComponent = _react19Renderer.RenderComponent("Components.FrontPage", propsJson);
return View(renderedComponent);
}
public async Task<ActionResult> Vue3()
{
var propsJson = JsonConvert.SerializeObject(
new {
title = "Vue 3 with SSR"
});
var renderedComponent = await _vue3Renderer.RenderComponentAsync("Components.Example", propsJson);
return View(renderedComponent);
}
}
}