Asked by:
limiting x per day to use action (search feature) asp mvc

Question
-
User2131089582 posted
I want to create dictionary website where it has search feature to find the meaning of word entered. But for free version i want to limit the search feature x per day. So for example i limit for 10 times to use search per a day. so when user reach more than 10 times using the feature search, user must wait for another day to use it. I have researched with keyword "throttling " on google, but i think i don't have enough information about that, anyone can help me to resolve the issue.
Sunday, July 28, 2019 12:23 AM
All replies
-
User1120430333 posted
I don't think what you are wanting to do is viable.
Sunday, July 28, 2019 9:37 AM -
User1860059286 posted
The simplest way would probably be to get user ip , count his search and block it for what ever time u want<br>Sunday, July 28, 2019 9:48 AM -
User475983607 posted
I want to create dictionary website where it has search feature to find the meaning of word entered. But for free version i want to limit the search feature x per day. So for example i limit for 10 times to use search per a day. so when user reach more than 10 times using the feature search, user must wait for another day to use it. I have researched with keyword "throttling " on google, but i think i don't have enough information about that, anyone can help me to resolve the issue.
Set the count in a cookie that expires in a day.
Sunday, July 28, 2019 12:33 PM -
User-1496088595 posted
It is possible to implement your use case by using ActionFilters in MVC, the same is implemented in
https://nuget.org/packages/MvcThrottleSunday, July 28, 2019 7:39 PM -
User1520731567 posted
Hi hocamahdi99,
I have a little idea:
You could create a new table,when a user run the search function,you could insert a data which stores the number of times and userId.
When the number>10 or the day time arrives at 24:00,you could empty this table.
Follow this logic, repeat the steps.
Best Regards.Yuki Tao
Monday, July 29, 2019 9:03 AM -
User-821857111 posted
The cookie approach suggested by mgebhard is the most frequently used solution for applying this kind of limit. It has its pros and cons. It is pretty easy to code and doesn't require that the user is registered, but cookies are browser-specific. Most users won't know, but savvy users could use multiple browsers on multiple devices to circumvent the limit.
The database approach requires more code, and it also requires that you can identify a "user", so registration would be required, even for the free service. However, unless users are allowed to create multiple accounts, this will prove more tricky to circumvent and is therefore more robust from your point of view.
I wouldn't recommend the IP address approach. They are not necessarily static and can be shared by multiple users, so you might end up telling someone that they have used their quota even though they actually haven't visited the site at all that day.
Monday, July 29, 2019 1:43 PM -
User2131089582 posted
How about if thy change the ip?
Monday, July 29, 2019 11:53 PM