c# – Update member of a API controller

I’m new to C# and .net core.

I’m playing a bit with the default ASP .net core + Angular application from Rider (and VS I think).

I wanted to do a simple controller that would increment a counter server side so that multiple client can display the server side value. In debug I can see that I get inside the “Get” method when a client connect or I clic the “Update counter” button from the client, however the update of the “counter” value does not persist. Could someone explain to me what happens?

Here is my controller

public class CounterController : Controller
    private int counter = 0;
    public int Get()
        this.counter += 1;
        return counter;