有什么方法可以在不锁定ASP.Net MVC站点的情况下使用会话? [英] Is there any way to work with sessions without locking on ASP.Net MVC site?

查看:54
本文介绍了有什么方法可以在不锁定ASP.Net MVC站点的情况下使用会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在 ASP.Net MVC 网站上无锁定地使用会话?

Is there any way to work with sessions without locking on ASP.Net MVC site ?

会话锁定机制会导致很多问题;

当您的网站变慢一点点时,用户开始按键盘上的F5".当他们这样做时,请求开始互相等待.所有这些请求都在IIS上以 RequestAcquireState 状态挂在IIS上的会话模块上.

When your site slow down little bit, users are start to hit "F5" on the keyboard. When they do this, requests are starting to wait each other. All those requests are hanging on IIS at "RequestAcquireState" state for session module.

如果用户同时发出请求,就会发生这种情况.因为IIS中的会话模块和默认会话提供程序(或通常是自定义的会话提供程序)同时具有锁定机制.

If a user made a simultaneous requests this will happen. Because session module in IIS and default session provider (Or generally custom ones) has both lock mechanism.

请参阅:

存在锁定,因为如果您不精心设计流程,则可以操纵您的工作流程.与性能问题相比,被黑客入侵对您来说是一个大问题...

There is locking, because your workflow can be manipulated if you are not carefully designed your process. Been hacked is way big problem for you comparing with performance issues...

但是,如果您为共享的,半一致的状态存储区设计了流程,(或者只是没有必要使用)我们可以完全消除锁定情况吗?

But if you designed your process for shared, semi-consistent state store, (Or simply maybe there is no need to use) can we remove locking situation from our way completely?

推荐答案

是的,我们可以使用" UnlockedStateProvider "从我们的方式中删除锁.

Yes we can remove lock from our way with "UnlockedStateProvider".

它是为MVC设计的,因此不实现.Net SessionStateStoreProviderBase,因为IIS会话模块也具有锁定机制.

It designed for MVC and not implements .Net SessionStateStoreProviderBase because, IIS session module also has locking mechanism.

这是一个简单的ActionFilterAttribute通过HttpContext为您提供状态存储.

It is a simple ActionFilterAttribute provide state store for you via HttpContext.

它还具有Redis提供程序,因此您可以在Web场,Azure或AWS中安全使用.

It has also Redis provider so you can use safely in web farm, Azure or AWS.

请看看:

注意: 为高级用法而开发,不能替代任何SessionStateProvider ...

这篇关于有什么方法可以在不锁定ASP.Net MVC站点的情况下使用会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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