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

Confusing with the Blazor CSR

$
0
0

I used the Auto render mode template, so VS 2022 created 2 projects for me.One is xxxProjectName, the other one is xxxProjectName.Client.

xxxProjectName is the project to be hosted in server,and the xxxProjectName.Client is the project to be downloaded to browser, am I right?

I want to put all logic at server side, so I expose a controller for Web API, and add HttpClient to xxxProjectName.Client to call the Web API.

After I added HttpClient service in Program.cs in xxxProjectName.Client, and try to inject it in Razor Page, it failed to find the HttpClient, only works if I add HttpClient service in Program.cs in xxxProjectName.I am confused, I set the @rendermode InteractiveAuto in the Razer Page in the xxxProjectName.Client, but why do I need to register the service in server side? If so, why do we need a xxxProjectName.Client project?

Another thing is why both xxxProjectName and xxxProjectName.Client have a Layout folder, and put MainLayout and NavMenu in different part?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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