Sample of gRPC web integration with grid component in Blazor
Hi ,
I'd like to thank your all for your great support.
Now the .net gRPC web for .Net is commited and production ready. Look at
https://devblogs.microsoft.com/aspnet/grpc-web-for-net-now-available/
Please provide us with a sample on how to integrate the grid component in Blazor (Wasm ) with gRPC
SIGN IN To post a reply.
2 Replies
1 reply marked as answer
RN
Rahul Narayanasamy
Syncfusion Team
June 24, 2020 05:19 PM UTC
Hi Mohamed,
Greetings from Syncfusion.
We have validated your query and we are facing some complexities while preparing sample based on the mentioned requirement. We will update the further details on June 25, 2020. Until then we appreciate your patience.
Regards,
Rahul
RN
Rahul Narayanasamy
Syncfusion Team
June 25, 2020 07:56 PM UTC
Hi Mohamed,
Thanks for your patience.
We have validated your requirement and created a sample(gRPC integration) based on your requirement. Please find the sample for your reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorAppgRPCFinal842484148
To get started, edit your shared project’s .csproj to add references to the necessary gRPC packages:
|
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.11.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.29.0" />
<PackageReference Include="Grpc.Tools" Version="2.29.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup> |
Now you can create a .proto file to define your services. Here, we have created weather.proto file inside the shared project.
To make the gRPC tooling generate server and client classes from this, go into your shared project’s .csproj and add the following reference(created weather.proto file).
|
<ItemGroup>
<Protobuf Include="weather.proto" />
</ItemGroup> |
In the same way, you need to add some reference to your server project’s .csproj. Find the reference list below.
|
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.29.0" />
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.29.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0" />
</ItemGroup> |
Then you need to configure the services in Starup.cs file in your server project.
In your client project’s .csproj, you’ll need to add some references(Grpc.Net.Client.Web) like we added in server and shared projects. Find the reference in the provided project and reference link.
Now set up your client app’s dependency injection system to be able to provide instances of WeatherForecastsClient. This will let you invoke the gRPC service from anywhere in your client app. In the client project’s Project.cs file.
Finally we have to call gRPC service from our component file and bind the data to Grid.
Find the below gRPC oriented links for your reference.
Reference:
Please get back to us if you have any concerns.
Regards,
Rahul
Rahul
Marked as answer
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
- Marked answer
-
MO Mohamed
- Jun 19, 2020 04:55 AM UTC
- Jun 25, 2020 07:56 PM UTC