Pass data from .NET code into TypeScript code #260

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

Originally created by @JCPuerto on 12/16/2017

Greetings,

This is related to the Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-preview1-final angular template.

In the Use the Angular project template page it says : "For example, see how main.server.ts passes the BASE_URL value to any component whose constructor is declared to receive it".

In the recently created file main.server.ts in the extraProviders section there's this { provide: 'BASE_URL', useValue: params.origin + params.baseUrl } line and I thought all I needed to do is create another entry like that one. However, it seems that the BASE_URL provider is actually ignored and is actually taken from the existing main.ts file. I could delete that provider in main.server.ts and nothing happens. If I delete the provider in the main.ts I get a No provider for BASE_URL error.

So could you please show us an example to get a custom value sent from .NET like the one you suggested in the article; data["isHttpsRequest"] = context.Request.IsHttps; ?.

Thank you very much!

Good work by the way. We really appreciated!

*Originally created by @JCPuerto on 12/16/2017* Greetings, This is related to the _Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-preview1-final_ angular template. In the [Use the Angular project template](https://docs.microsoft.com/en-us/aspnet/core/spa/angular?tabs=visual-studio) page it says : "For example, see how main.server.ts passes the BASE_URL value to any component whose constructor is declared to receive it". In the recently created file **main.server.ts** in the `extraProviders` section there's this `{ provide: 'BASE_URL', useValue: params.origin + params.baseUrl }` line and I thought all I needed to do is create another entry like that one. However, it seems that the BASE_URL provider is actually ignored and is actually taken from the existing **main.ts** file. I could delete that provider in main.server.ts and nothing happens. If I delete the provider in the main.ts I get a `No provider for BASE_URL` error. So could you please show us an example to get a custom value sent from .NET like the one you suggested in the article; `data["isHttpsRequest"] = context.Request.IsHttps;` ?. Thank you very much! Good work by the way. We really appreciated!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#260
No description provided.