简体   繁体   English

为什么ASP.NET重新启动WCF服务?

[英]Why ASP.NET restarting WCF service?

i have a problem. 我有个问题。 I am developing ASP.NET app with WCF service. 我正在使用WCF服务开发ASP.NET应用程序。 There is a custom session manager, which based on SessionID. 有一个基于SessionID的自定义会话管理器。 I'm keeping session ids in static class, which stored in assembly with WCF service. 我将会话ID保留在静态类中,该类存储在WCF服务的程序集中。

Sometimes, WCF service unexpectely restarts (or recreates?) and session manager clears with all ids of opened sessions. 有时,WCF服务意外重启(或重新创建?),并且会话管理器清除所有已打开会话的ID。 It's unacceptable in this project. 在这个项目中这是不可接受的。

I readed about the InstanceContextMode/ConcurrencyMode attributes and a set them to "Single", but it has no effect: WCF service restarts all the same. 我阅读了有关InstanceContextMode / ConcurrencyMode属性的信息,并将它们设置为“ Single”,但它没有任何作用:WCF服务将全部重新启动。

How to disable WCF service restarting? 如何禁用WCF服务重启?

IIS may recycle application pool hosting your application for many different reasons. IIS可能出于多种原因回收承载您的应用程序的应用程序池。 It means that the process hosting your application will be restarted and all data saved in static fields or classes will be lost. 这意味着托管应用程序的进程将重新启动,保存在静态字段或类中的所有数据都将丢失。

In order to fix this I would suggest keeping your data in database or some other persistent storage instead of a memory. 为了解决此问题,我建议将您的数据保留在数据库或其他持久性存储中,而不是内存中。 If this data is used very frequently you may consider creating in-memory cache on top of this persistent storage. 如果经常使用此数据,则可以考虑在此持久性存储之上创建内存中缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM