ASP.NET MVC 对象锁定机制

发布于 2024-08-24 03:43:06 字数 403 浏览 5 评论 0原文

我正在开发一个 ASP.NET MVC 2 Web 应用程序,该应用程序允许用户编辑模拟参数并启动它。一旦用户开始编辑特定模拟,其他用户就必须无法访问它。

在 ASP.NET MVC 中是否有一种简单的方法可以实现该目标?

我的第一个想法是将登录用户的身份与模拟一起放入应用程序集合中: Application.Add((Guid)Membership.GetUser().ProviderUserKey,simulationId);

然后,当会话过期时,我会在 Session_End 方法中删除它。但是,永远不会使用 web.config 文件中的这些参数调用 Session_End 方法: sessionState mode="InProc" timeout="1"

我做错了什么? / 有更好的机制吗?

I'm working on a ASP.NET MVC 2 web application that lets users edit parameters on a simulation and launch it. Once a user starts editing a specific simulation, it must be inaccessible to other users.

Is there an easy way to achieve that goal in ASP.NET MVC?

My first idea was to put the logged on user's identity in the Application collection, along with the simulation:
Application.Add((Guid)Membership.GetUser().ProviderUserKey, simulationId);

Then I would remove it in the Session_End method, when the session expires. However, the Session_End method is never called with those parameters in the web.config file:
sessionState mode="InProc" timeout="1"

What am I doing wrong? / Is there a better mechanism?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋日私语 2024-08-31 03:43:06

在网络应用程序中很难做到。你能告诉我们为什么吗?通常在这种情况下使用冲突检测,并且第一个更新者获胜。第二个更新程序可以被告知“刷新数据并重试”,或者您可以尝试应用或合并更改并提议保存较新的版本。

Hard to do in a web application. Can you tell us why? usually collision detection is used in this instance and the first updater wins. The second updaters can either be told "refresh your data and retry" or you can try to apply or merge the changes and offer to save the newer version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文