#啟動state服務

#連接state服務

#修改iis站台名稱
#在根目錄下新增一個Global.asax,程式代碼如下
每個應用程序名稱必須一致,才有可能共享session
appName可自行定義
<%@ Application Language="C#" %>
<script runat="server">
protected void Application_Start(object sender, EventArgs e)
{
//使用反射來取得 HttpRuntime 的實例
System.Reflection.FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null);
//使用反射來設定應用程式域名稱
System.Reflection.FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
appNameInfo.SetValue(theRuntime, "appName");
}
</script>