1
我需要在某些時刻檢查會話大小。我怎樣才能做到這一點?如何檢查Asp.Net WebForms會話大小
我不得不試圖創建掠影自定義選項卡,但會話對象總是空:
public override object GetData(Glimpse.Core.Extensibility.ITabContext context)
{
var result = new List<string[]> { new[] { "Object", "Number of bytes" } };
HttpContextBase context1 = context.GetHttpContext();
HttpSessionStateBase session = context1.Session;
if (session != null)
{
long totalSessionBytes = 0;
BinaryFormatter b = new BinaryFormatter();
MemoryStream m;
foreach (var obj in session)
{
m = new MemoryStream();
b.Serialize(m, obj);
result.Add(new[] { obj.ToString(), m.Length.ToString() });
totalSessionBytes += m.Length;
}
result.Add(new[] { "Total", totalSessionBytes.ToString() });
}
else
{
result.Add(new[] { "Session", "Null" });
}
return result;
}
我也試過這樣:
https://github.com/jasonrclark/Glimpse/commit/89416a7e7934d98a02839fc7976a288ca18f6d60
但我無法找到任何IGlimpsePlugin接口。
謝謝!覆蓋RuntimeEvent ExecuteOn屬性是解決方案。 –