最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Blazor .NET 9 web app with renderMode=Auto; clarification - Stack Overflow

programmeradmin0浏览0评论

I'm exploring Blazor .NET 9 web apps, using rendermode set to auto (Server + Wasm). You can notice that a shared project is not created, but only Server and Client. In this context, the Layout and Pages folders also resides in the Client project, and so far everything is ok.

In this context, I also tried to insert the following code

<p>@RendererInfo.Name</p>

on the Home and I noticed how at the first start the render is executed on the Server. As soon as the download in the background on the Browser is finished, the render actually becomes WASM.

However, I was wondering why there is no SHARED project or if there is some technique or new method to ensure that data can be manipulated from the client. In other words, if you want to transfer information to a shared database, with this paradigm, you must always refer to the DataService and the controller on the server to interact with it (and in this case it seems obvious to me to create a shared project to share the classes that represent the data layer) or have I missed something?

I'm exploring Blazor .NET 9 web apps, using rendermode set to auto (Server + Wasm). You can notice that a shared project is not created, but only Server and Client. In this context, the Layout and Pages folders also resides in the Client project, and so far everything is ok.

In this context, I also tried to insert the following code

<p>@RendererInfo.Name</p>

on the Home and I noticed how at the first start the render is executed on the Server. As soon as the download in the background on the Browser is finished, the render actually becomes WASM.

However, I was wondering why there is no SHARED project or if there is some technique or new method to ensure that data can be manipulated from the client. In other words, if you want to transfer information to a shared database, with this paradigm, you must always refer to the DataService and the controller on the server to interact with it (and in this case it seems obvious to me to create a shared project to share the classes that represent the data layer) or have I missed something?

Share Improve this question edited Feb 2 at 11:33 marc_s 755k184 gold badges1.4k silver badges1.5k bronze badges asked Feb 2 at 11:13 Luca C.Luca C. 3074 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

There is no Shared project because the template does not contain an API that would benefit.

But it's very easy to fix, just add a Class library and reference it from the Client and from the API (which might be your Server, or not).

Note that for Components and UI logic you already have a common project: the Client is refenced from the Server.

发布评论

评论列表(0)

  1. 暂无评论