---
# System prepended metadata

title: MagicOnion gRPC `Connection id` の取得  2021-10-06
tags: [MagicOnion, gRPC, Connection id]

---

---
lang: ja-jp
breaks: true
---
# MagicOnion gRPC `Connection id` の取得  2021-10-06

![](https://i.imgur.com/4eKFGJM.png)


## サービス側

サービスメソッド内にて

```csharp=
using Grpc.Core;
```

```csharp=
public async UnaryResult<int> SumAsync(int x, int y)
{
    string id = base.Context?.CallContext?.GetHttpContext()?.Connection.Id;        
    return x + y;
}
```

###### tags: `MagicOnion` `gRPC` `Connection id`
