Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to connect to server side projct in blazor with .NET 9 from client project

$
0
0

I have created a Blazor web assembly project that has two projects: a server-side and a client-side project. However, in .NET 8 and .NET 9, it is not possible to access the resources of the server-side project through client components.

I tried to define HttpClient in Program.cs in both the client and server projects, but in the server project, I can't get the address of the site:

builder.Services.AddScoped(sp => new HttpClient                                      {                                          BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)                                      });

The server project can not find the HostEnvironment.BaseAddress.

How I can resolve this problem?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>