Q:

Track amount of webservice calls by same user

I'm currently developing a web-service based application that needs to track how often a specific client called it in a certain time frame. The service is set up in a way where the client calls one specific url, which triggers one specific function; the service does whatever it needs to do and spits out a response that gets interpreted into a webpage-like UI by the client. 
On that page, there is a retry button that calls the same link again, which restarts the application from the very beginning. This cannot be changed, I have no control over the post parameters and the entire application gets restarted every time.
It would look something like this:
//user calls www.imawebservice.com/dosomething.svc/somemethod

public class dosomething
{
    public Response somemethod()
    {
        //do things
        int counter = GetCounterSomehow(); // help please
        if(counter > someLimit) return Response("go away");
        counter++;
        Response response = new Response(
            new Link("www.imawebservice.com/dosomething.svc/somemethod"))
        return response;
    }
}

Except for a database, how can I save simple key-value pairs between web service self-calls, at best natively in C#? If this is a timeout based process, even better.
Edit: This data is not supposed to be kept for long. This is a simple counter that gets discarded after a certain time period or based on a certain condition in the flow of the service. All that is needed is a C# mechanism to essentially cache a simple key-value pair in between service calls.
Edit 2: Added a reason for why Im counting into the code for more clarity.

A:

Assuming "external libraries" doesn't include standard .Net libraries you could reference System.Runtime.Caching, and do something similar to this. There are overloads which allow you to use time based expiration.
   public class dosomething
    {
    public Response somemethod()

        ObjectCache cache = System.Runtime.Caching.MemoryCache.Default;  
         int counter = (int?)cache["userId"] ?? 0;

        if (counter>=1000) return; //example max calls threshold

        cache.Set("userId", counter +1, DateTimeOffset.Now.AddHours(1));   

        Response response = new Response(
            new Link("www.imawebservice.com/dosomething.svc/somemethod"))
        return response;
    }
}

