它不..完全真實..你可以做這樣的使用反射:
var privateFieldFlags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
//Get session state section
var sessionStateSection = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection;
var values = typeof(ConfigurationElement).GetField("_values", privateFieldFlags).GetValue(sessionStateSection);
var entriesArray = values.GetType().BaseType.GetField("_entriesArray", privateFieldFlags).GetValue(values);
//Get "Mode" entry (index: 2)
var modeEntry = (entriesArray as System.Collections.ArrayList)[2];
var entryValue = modeEntry.GetType().GetField("Value", privateFieldFlags).GetValue(modeEntry);
//Change entry value to InProc
entryValue.GetType()
.GetField("Value", privateFieldFlags)
.SetValue(entryValue, System.Web.SessionState.SessionStateMode.InProc);
引用:
Dynamic session state provider
http://www.answerandquestion.net/questions/4447903/dynamic-session-state-provider
我不知道,爲什麼你認爲鏈接解決方案不健壯。此外,作爲回退,當您的Web應用程序部署在網絡服務器場(20臺前端服務器)時,您不應該退回到InProc – Ramesh 2012-07-27 02:40:03