我有一个Angular 5应用程序,我希望使用最新的Angular模板RC在ASP.net Core上使用Angular Universal .我已经按照文档操作并启动并运行了应用程序.问题是我也在使用Angular的i18n工具,它生成多个编译的应用程序,每个语言环境1个.我需要能够主持每一个https://myhost.com/{locale}/
.
我知道我可以为每个区域设置启动ASP.net核心应用程序的实例,并在网络服务器中设置托管以使相应的路径路由到关联的应用程序,但这对我来说似乎过分了.
路由配置为:
// app is an instance of Microsoft.AspNetCore.Builder.IApplicationBuilder
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
SpaServices配置有:
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
spa.UseSpaPrerendering(options =>
{
options.BootModulePath = $"{spa.Options.SourcePath}/dist-server/main.bundle.js";
options.BootModuleBuilder = env.IsDevelopment()
? new AngularCliBuilder(npmScript: "build:ssr:en")
: null;
options.ExcludeUrls = new[] { "/sockjs-node" };
options.SupplyData = (context, data) =>
{ …
Run Code Online (Sandbox Code Playgroud)