バックグラウンド
- .NET3.5を使用してIIS6(Win2003 Server)で実行されている1つのWebサイトがあります:site1.mysite.local
- .NET4.0を使用してIIS7(Win2008 Server)で実行されている2番目のWebサイトがあります:site2.mysite.local
各サイトで、web.configにはStateServerと同じmachineKeyが含まれています。
<sessionState mode="StateServer" stateConnectionString="tcpip=STATESRV01:42424" />
<machineKey decryptionKey="EDCDA6DF458176504BBCC720B4E29348E252E652591179E2" validationKey="CC482ED6B5D3569819B3C8F07AC3FA855B2FED7F0130F55D8405597C796457A2F5162D35C69B61F257DB5EFE6BC4F6CEBDD23A4112C4519F55185CB5EB3DFE61"/>
また、同じルートドメインとパスを持つように「NET_SessionId」Cookieを変更するPostRequestHandlerExecuteイベントハンドラーもあります。
cookie.Domain = ".mysite.local";
cookie.Path = "/";
global.asaxファイルには、Application_Startイベントのアプリ名を変更するための次のコードがあります。
protected void Application_Start(object sender, EventArgs e)
{
string applicationName = "mysiteapp";
// Change the Application Name in runtime.
FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime",
BindingFlags.Static | BindingFlags.NonPublic);
HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null);
FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId",
BindingFlags.Instance | BindingFlags.NonPublic);
appNameInfo.SetValue(theRuntime, applicationName);
}
結果
両方のサイトが同じセッションIDを返しますが、site1にセッション値を設定しようとすると、site2は値を返しません。
サイト1(site1.mysite.local)結果
Session ID (Session.SessionID): a55jnfcscxd3f0hnwoik02pp
Session Value: True
サイト2(site2.mysite.local)結果
Session ID (Session.SessionID): a55jnfcscxd3f0hnwoik02pp
Session Value:
質問
私の理解では、State Serverは、SessionID cookie、マシンキー、および更新しようとしたアプリ名の組み合わせからセッションにキーを設定し、両方のサイトで同じになるようにします。問題は、セッション値がWebサイト間で共有されていないことです。
セッション状態にSQLServerモードを使用してみませんか?
必要かもしれませんが、代わりにStateServerを使用したいと考えていました。
複数のサーバーにまたがる複数のWebアプリケーションを備えたStateServerで成功した人はいますか?