Add example of full-page prerendering via a custom action result

This commit is contained in:
SteveSandersonMS
2016-07-19 15:50:54 +01:00
parent edf1f88398
commit 749c7cb3ce
8 changed files with 115 additions and 4 deletions

View File

@@ -0,0 +1,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);
}
}
}