forked from aspnet/JavaScriptServices
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFullPagePrerenderingController.cs
More file actions
25 lines (23 loc) · 918 Bytes
/
Copy pathFullPagePrerenderingController.cs
File metadata and controls
25 lines (23 loc) · 918 Bytes
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
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.Prerendering;
using Webpack.ActionResults;
namespace Webpack.Controllers
{
// This sample shows how you could invoke the prerendering APIs directly from an MVC
// action result.
public class FullPagePrerenderingController : Controller
{
private static JavaScriptModuleExport BootModule = new JavaScriptModuleExport("Clientside/PrerenderingSample")
{
// Because the boot module is written in TypeScript, we need to specify a webpack
// config so it can be built. If it was written in JavaScript, this would not be needed.
WebpackConfig = "webpack.config.js"
};
public IActionResult Index()
{
var dataToSupply = new { nowTime = DateTime.Now.Ticks };
return this.Prerender(BootModule, dataToSupply);
}
}
}