realPro
realPro

Reputation: 1846

Can I limit access to asp.net mvc controller per user HTTP request?

I have this simple controller:

   [HttpGet, ActionName("analysis")]
        public async Task<StatusResultModel> Analysis(Guid api_key)
        {Thread.Sleep(10000);}

What I need to achieve, is to limit the access per user base, so that each user will be able to make only one HTTP request to this controller.

So if someone makes two parallel requests, the first request stars processing, but the second request will block until the first one is not done.

Upvotes: 0

Views: 194

Answers (1)

Kinexus
Kinexus

Reputation: 12904

You will need to store the state of requests by each api key and manage this accordingly. Add an entry to your state when they start, check for existence on each request, and remove when done.

Upvotes: 2

Related Questions