锁定在asp.net页面为用户 [英] Locking the page in asp.net for a user

查看:102
本文介绍了锁定在asp.net页面为用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临的一个问题,锁定一个asp.net页面。我们有我们需要锁定该页面谁首先打开它的用户的用户个人资料页面。详细情况如下,也有很多的数据库用户配置文件中的记录和我们传递记录编号查询字符串打开一个特定的页面。用户点击在网格中一个LinkBut​​ton,并打开只读模式记录。有一个编辑按钮使所有的控制,使他一旦点击它,它提供给用户。我们的任务是锁定记录谁第一个点击编辑按钮用户。

I am facing a problem with locking an asp.net page. We have a user profile page in which we need to lock that page for the user who opened it first. The details are as follows, There are many user profile records in database and we are passing the record number to querystring to open a particular page. The user clicks a linkbutton in a grid and opens the record in readonly mode. There is an edit button which enables all the controls and makes it available to user once he clicks it. The task is to lock the record to the user who clicks the edit button first.

除了这个还有很多场景,如用户可以从网页浏览或者他可能在两者之间关闭页面。在这些情况下,记录应提供给其他用户。
请给我如何解决该方案的一些可能的方法或例子。

Apart from this there are many scenarios like the user may navigate from the page or he may close the page in between. In these cases the record should be available to the other users. Please give me some possible approaches or examples of how to solve the scenario.

在此先感谢

推荐答案

有关良好的用户体验,我会设置在页面上心跳用户点击编辑使用一些JavaScript后。每5秒或任何更合理我ping服务器。因此,如果用户断开连接无论出于何种原因,你可以通过分拆检查,看看最后一次用户ping通的页面线程快速释放锁pretty。你不得不存储一些平的​​时候,像服务器缓存或者会话,但我preFER像内存缓存负载平衡(虽然它可能不是在您的环境很重要)分布式缓存。

For a good user experience, I'd setup a heartbeat on the page after a user clicks "edit" using some javascript. Every 5 seconds or whatever is more reasonable I'd ping the server. So if the user disconnects for whatever reason you can release the lock pretty quickly by spinning off a thread that checks to see the last time the user pinged the page. You'd have to store the ping time somewhere, like the server cache or maybe the session, but I'd prefer a distributed cache like memcache for load balancing (although it might not be important in your environment).

锁本身应该是相当容易实现,但我偏向喜欢的memcache无论是分布式的缓存解决方案,或在数据库中的时间戳列。我仍然有故障保护到期的情况下,它不会通过心跳过期。

The lock itself should be fairly straightforward to implement, but I'd favor either distributed cache solution like memcache or a timestamp column in the database. I'd still include a failsafe expiration in case it doesn't expire through the heartbeat.

这篇关于锁定在asp.net页面为用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆