asp-prerender-data values not passed to boot-server.ts #922

Closed
opened 2025-08-09 17:18:11 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @JohnGalt1717 on 3/20/2017

Using the Angular2 template I have the following in my index.cshtml:

@{
var serviceUrl = System.Environment.GetEnvironmentVariable("ApiUrl");
var blogUrl = System.Environment.GetEnvironmentVariable("ApiUrl");
if (string.IsNullOrWhiteSpace(serviceUrl))
{
serviceUrl = options.Value.ApiUrl;
}
if (string.IsNullOrWhiteSpace(blogUrl)) {
blogUrl = options.Value.Url;
}

ViewData["Title"] = "CADLearning Blogs";

var serviceData = new {
    ServiceUrl = serviceUrl,
    Url = blogUrl
};

}

Loading...

and then in my boot-server.ts I have the following:

export default createServerRenderer(params => {
return new Promise((resolve, reject) => {
throw params.data.ServiceUrl;
...

I'm attempting to verify that it's actually being passed to the params.data per the docs. params.data returns [Object object] but params.data.ServiceUrl returns undefined.

I think I've tried every permutation and combination of the above there is with no joy, the values are never passed through.

what am I doing wrong?

*Originally created by @JohnGalt1717 on 3/20/2017* Using the Angular2 template I have the following in my index.cshtml: @{ var serviceUrl = System.Environment.GetEnvironmentVariable("ApiUrl"); var blogUrl = System.Environment.GetEnvironmentVariable("ApiUrl"); if (string.IsNullOrWhiteSpace(serviceUrl)) { serviceUrl = options.Value.ApiUrl; } if (string.IsNullOrWhiteSpace(blogUrl)) { blogUrl = options.Value.Url; } ViewData["Title"] = "CADLearning Blogs"; var serviceData = new { ServiceUrl = serviceUrl, Url = blogUrl }; } <app asp-prerender-module="ClientApp/dist/main-server" asp-prerender-data="serviceData">Loading...</app> and then in my boot-server.ts I have the following: export default createServerRenderer(params => { return new Promise<RenderResult>((resolve, reject) => { throw params.data.ServiceUrl; ... I'm attempting to verify that it's actually being passed to the params.data per the docs. params.data returns [Object object] but params.data.ServiceUrl returns undefined. I think I've tried every permutation and combination of the above there is with no joy, the values are never passed through. what am I doing wrong?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#922
No description provided.