如何从Web应用程序中找到会话的大小在ASP.NET? [英] How to find out size of session in ASP.NET from web application?
本文介绍了如何从Web应用程序中找到会话的大小在ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Web应用程序中找到会话的大小在ASP.NET?
How to find out size of session in ASP.NET from web application?
推荐答案
如果你想运行,而不是在调试跟踪中获得会话的大小,你可能想尝试这样的事:
If you're trying to get the size of Session during runtime rather than in debug tracing, you might want to try something like this:
long totalSessionBytes = 0;
BinaryFormatter b = new BinaryFormatter();
MemoryStream m;
foreach(var obj in Session)
{
m = new MemoryStream();
b.Serialize(m, obj);
totalSessionBytes += m.Length;
}
(由<一个启发href=\"http://www.$c$cproject.com/KB/session/exploresessionandcache.aspx\">http://www.$c$cproject.com/KB/session/exploresessionandcache.aspx)
这篇关于如何从Web应用程序中找到会话的大小在ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文