我在两个web应用程序之间使用了sql server会话模式。会话ID是在ASPState数据库中创建的。我需要在不使用查询字符串和cookie的情况下从第一个应用程序共享会话ID到第二个应用程序。我按照这个链接的步骤进行操作。以下是代码。
在两个应用程序中(web.config)
<add name="DBConnection" connectionString="Data Source=localhost;DataBase=ASPState;Integrated Security=True;uid=sa;pwd=password-1" providerName="System.Data.SqlClient"/>
<sessionState mode="SQLServer" sqlConnectionString="DBConnection" allowCustomSqlDatabase="true" regenerateExpiredSessionId="false" cookieless="false" timeout="1" ></sessionState>
<machineKey validationKey="566A547C407CB0C47ABAEC581B8B90C45E15039806352E4611B35E0FB70C1C096350A4BBAE816191331DCA55874D3F96B41FFDED4C6A913591684A90825F53A0" decryptionKey="B299127DFC22648C2EF92D7EDF2E4960277F562C60F3BDE4A4C3BFDFEA602FDF" validation="SHA1" decryption="AES" />
<modules runAllManagedModulesForAllRequests="true">
<add name="BasicAuthenticationModule" type="UserAuthenticator" />
</modules>
在第一个应用程序中,Home.aspx.cs 文件中:
protected void imgBTN_Click(object sender, EventArgs e)
{
string sessionKey = HttpContext.Current.Session.SessionID;
//How to transfer the same session id to the second application
Response.Redirect("http://localhost:43392/PartnerHome.aspx"");
}
我从ASPState数据库中获取了会话密钥。但是如何将相同的会话ID传递到第二个应用程序中呢?
WebClient
或WebRequest
- 你会发现有很多关于如何使用POST请求的例子。 - VinayC