I have a Blazor Server app that calls an aspx net core web API. In program.cs I set up the application as an HttpClient service and inject it into my web page. In production, the entire application (both the service and the Blazor app) are delivered on different servers. I need to be able to display the BaseAddress of the web API on a Blazor page - the URL will be different on different servers of course.
If I inject the service into my Blazor page I only get a reference to the functions available in the controller, not the properties of the service itself. How can I access the info that was specified in Program.cs for the service?
in Index.razor
@code {
[Inject]
public MyAspx myservice { get; set; }
protected override async Task OnInitializedAsync()
{
var baseurl = myservice.BaseAddress; // for illustration purposes only this is what i need, not what it will provide
}
}
in Program.cs:
builder.Services.AddHttpClient<IMyAspx, MyAspx>(client =>
{
client.BaseAddress = new Uri("https://localhost:7132/");
client.Timeout = TimeSpan.FromMinutes(1);
});