Instead of setting a global session timeout (you never know when you might want to start using session objects), you could use MemoryCache with an absolute expiration. With this generic method:
public T PreventAction<T>(string uniqueUserId, string action, DateTimeOffset absoluteExpiration, Func<T> callback) where T : class
{
string key = uniqueUserId + action;
T item = MemoryCache.Default.Get(key) as T;
if (item != null)
return null;
MemoryCache.Default.Add(key, item, absoluteExpiration);
return callback();
}
You could prevent a user from doing 'something' every x amount of time by implementing the following code:
// User should only be allowed to calculate 2+2 every 15 minutes
PreventAction(uniqueUserId, "Calculate2+2", DateTime.Now.AddMinutes(15), () =>
{
var calculation = 2+2;
Console.WriteLn(calculation);
});