简体   繁体   中英

Why are static variable data lost and not instance when restarting IIS/app pool recycling?

Why is that if I restart IIS, a static variable's data is lost (eg in a webpart property in Sharepoint) but in an instance variable, this is not the case?

This is with IIS7 and Windows Server 2008 R2 x64.

Thanks

If a process is restarted, all variables are lost. But: IIS automatically serializes the session variables into another processes memory when a pool is recyled. When the pool restarts, the session variables are deserialized and thus, restored. This is done with the .NET serialisation feature, which means that all session variables has to be marked with the [Serializable] attribute, otherwise you get runtime excpetions.

实例变量肯定失去-这只是大概他们正在通过请求数据重新填充,只是因为他们没有重新启动IIS时。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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