Technique for user license implementation in asp.net mvc
Currently i'm searching for a technique to create a named user license system
with asp.net mvc. For example a customer has bought 10 user licenses, it should
only be possible, to log in 10 times parallel.
The problem I'm struggeling with, is the fact that there is no permanent
connection in web technologies. (Between client and server, besides using web sockets or some similar things).
A possible solution (which may or may not be the right one for you), is to store the amount of sessions a user currently has and is allowed to have in two columns in your database.
Let's say you have the functions login(username, password) and logout(username), or something similar. Then, you need two new columns in your database, one storing the maximum amount of sessions a user can have, e.g. maxSessions , the other one containing the current count of sessions a user has, e.g. curSessions.
Now you can check with every call of login(username, password) if a user has reached the maximum of allowed sessions, and deny his access to your service. If he hasn't, add 1 to curSessions, then run your other login code. If logout(username) gets called, remove 1 from curSessions, and run your logout code.
If I understood your question the right way, this is what you were looking for.
Asked in February 2016Viewed 1,498 timesVoted 10Answered 1 times