Reputation: 641
I have an asp.net page to edit an entity. What is the best design pattern to notify and prevent saving when another user is already on the edit page for that entity. I would want the lock to expire when the user leaves the page. I would also like to display the user name that has the page locked.
Session state could be either inproc or state server.
The user needs to know before attempting to save (for example disable the save button for all other users on the edit page)
Upvotes: 0
Views: 629
Reputation: 370
There are many different ways to do this, but in general it is fairly complex. One challenge to be aware of is that you don't know when a user leaves a page as there is no way to signal that.
One approach that I've seen used a few times is to do the following:
Locked_User_ID
etc to your table)Locked_Timestamp
)Locked_Timestamp
& Locked_User_ID
).Locked_User_ID
to the current user and Locked_Timestamp
to the current date.Another slight variation of this to have a "check-out" or "edit" button/functionality that implements this - so that users can view information without automatically acquiring a lock on it, and only once they click "check-out" or "edit" does it check and acquire the lock.
Hope this helps!
Regards,
Ross
Upvotes: 5