B
B
babaevmm2016-11-06 19:41:22
ASP.NET
babaevmm, 2016-11-06 19:41:22

How to set a limit on the number of requests for certain users in MVC 5?

Hello!
Site + API on MVC 5. There is a method that should be available for testing for NOT authorized users, let's say 5 calls per day. For authorized 10 times a day. And for those who paid for the service, already according to the tariff. This method will be in both the MVC controller and the API. How to create such a constraint for MVC and API? When searching, I came across only a time limit for requests (let's say no more than 1 time for a certain period). Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Zhidkov, 2016-11-06
@babaevmm

It's not clear what the problem is. For each user, its own role, in accordance with this, analyze the rights ... then add to the table. additional users. a field of the int type, store the counter in it ... well, analyze it as usual, if it is more than 5 then block it, reset the counter at zero hours .... You can determine the user role through [Authorize (Roles = "Moder")] or User .IsInRole...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question