0

In an online B2B application (build using ASP.NET webforms on .Net framework 4.7.2), we want to restrict users to open 3 to 4 tabs of a browser at a time to control the load on server, as the no. of users is high, unlimited tabs by users may impact its performance.

We tried to add JS code at Option Link to count no. of options opened by users, But how to control closing of tabs?

Wasim
  • 1
  • 2
  • Server load is something you will want to control at the server, one idea is at the server end throttle requests based on user or even IP. Doing something like this in node would be very easy using a middleware, but I'm not sure how .Net framework does, I would assume you can create middleware handlers too. If a user then opens 50 tabs, it will then go slow for them and not impact other users. – Keith Jun 06 '23 at 12:33
  • As @Keith suggests, writing middleware to accomplish your task makes sense. See this link for more info: https://learn.microsoft.com/en-us/aspnet/core/performance/rate-limit?view=aspnetcore-7.0 – SoftwareDveloper Jun 06 '23 at 16:45

1 Answers1

1

seems like that you want achieve, that is very difficult in client side, because at the end of scenario we have to depend for server for count, and If you can achieve this by JS(by calling AJAX), still It will not correct all the time(like It will not work in browser crash or anything It may be).

So I am telling another solution which is best suitable for this one I think, you can create webSocket connection for every logged in user, and then check If that user has max connection then you can simply display prompt,

advantage of this solution is: You can also check cross browser(Like If someone is logged in one browser and open 3 tabs, and same user also use another browser and also using 3 tabs there, you can simply take over this too).

Thanks, Let me know if you have any query/question. I will try to give best solution :)

  • 1
    I tend to agree. Creating a websocket is the best solution. Now, one can "roll" their own prototalcall with web sockets, or adopt a pre-made framework based on web sockets that does all this dirty work for you. SignalR is a thus a good choice, since starting with JUST WebSocket's means you have to build some type of communication protocol here from scratch (not too hard), but SignalR would save a lot of effort and time. So, 100% agree with this advice. start here: https://learn.microsoft.com/en-us/aspnet/signalr/overview/getting-started/introduction-to-signalr – Albert D. Kallal Jun 06 '23 at 17:34