devspider
devspider

Reputation: 207

How to implement only one user can access a certain the page - MVC 3

I have a page for editing product details. I want to restrict that only one user can edit the product page. When a new user opens it while there is a current user editing it, I would like to place some notification then automatically make it available once the current user leaves the page. Any suggestion on how I should approach this?

Upvotes: 0

Views: 855

Answers (4)

BizApps
BizApps

Reputation: 6130

Try something like this:

Create a table something like userAccess with IsAccessColumn

if user 1 access edit page set isAccess to True

So the second user will not access the edit page if records is set to true.

Then Set to False if user 1 finally edited the record

After that user 2 can now open edit page.

Regards

Upvotes: 0

Ranu Mandan
Ranu Mandan

Reputation: 286

you can have optimistic lock on your record while it is in edit mode , once it is saved make that record avaliable for other user.

Upvotes: 0

John Gietzen
John Gietzen

Reputation: 49564

I would recommend just letting them both edit at the same time.

If you want to notify the last person to save their document, then you can add a "version" column to the database.

Upon saving, you would check the version column, to ensure that the row had not been changed. If it had been changed, you would notify the user at that point.

Upvotes: 1

Ashok Padmanabhan
Ashok Padmanabhan

Reputation: 2120

If i understand you question correctly it sounds like you need to know about database concurrency, Here are a couple of articles: MSDN Ironspeed

Now if you are asking how to authorize only a single user to edit records then you would need to look at roles and aloow say only admins to edit records.

Upvotes: 0

Related Questions