Last post Sep 15, 2015 07:00 AM by PatriceSc
Sep 13, 2015 10:43 AM|joydeepsen|LINK
In my asp.net web application I have a edit page which is used to edit the entities.
Now is it possible to restrict other sessions to access the same page (edit mode) while it is already in process by a session?
Can you please share a solution for this problem?
How can we restrict multiple client session (from different browser, or system or) to access the Edit page.
Thanks in advance.
Sep 13, 2015 02:09 PM|XIII|LINK
as Session state is a per user state it's not possible to check if another user is already making use of it. You need something like Cache in which you can put the username of the person who's currently editing the page/information. Of course this doesn't
come without potentials errors: what if the person who's in edit mode needs to go home suddenly due to illness or a meeting? Will the page be released for others or not?
Carefully think out your strategy and foresee potential pitfalls as the one I described above.
Another technique would be to make use of SignalR where you keep the state of who's editing the page/information on the server while others can still see the page/information. If the other person gives the signal that she's done editing then a signal to
other users might be sent that it's again possible to edit. Or you could keep some queue on the server side where you keep track of the users who requested editing permissions so it becomes a FIFO system.
Sep 14, 2015 03:29 AM|joydeepsen|LINK
Thank you Kris,
If these are the only options I will look into each of the options and see which one fits my need the most.
Thanks and Regards
Sep 14, 2015 03:56 AM|XIII|LINK
another option might be to store some bit flag in the database that it's being edited and the username. Once the person is done editing clear the flag and username. This is a safer way considering process recycles and such.
Sep 15, 2015 07:00 AM|PatriceSc|LINK
For data editing a known approach is to use optimistic concurrency:
In short, you can even have a version column on each row and when the row is updated his version number is checked allowing to ensure that nobody changed the row since you read it...