locked
Preventing a page edit when used by a session RRS feed

  • Question

  • User1580727775 posted

    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.

    Sunday, September 13, 2015 10:43 AM

Answers

  • User541108374 posted

    Hi,

    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.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 13, 2015 2:09 PM
  • User541108374 posted

    Hi,

    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.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 14, 2015 3:56 AM
  • User753101303 posted

    Hi,

    For data editing a known approach is to use optimistic concurrency: https://msdn.microsoft.com/en-us/library/aa0416cz(v=vs.110).aspx

    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...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 15, 2015 7:00 AM

All replies

  • User541108374 posted

    Hi,

    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.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 13, 2015 2:09 PM
  • User1580727775 posted

    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

    Joydeep

    Monday, September 14, 2015 3:29 AM
  • User541108374 posted

    Hi,

    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.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 14, 2015 3:56 AM
  • User753101303 posted

    Hi,

    For data editing a known approach is to use optimistic concurrency: https://msdn.microsoft.com/en-us/library/aa0416cz(v=vs.110).aspx

    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...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 15, 2015 7:00 AM