我想维护 http 请求 Cookie:ASP.NET_SessionId
目前我在所有网页上都得到了相同的 Cookie:ASP.NET_SessionId ,我想在每次登录时生成 Cookie:ASP.NET_SessionId 。
我确实尝试过 Global.asax.cs ,但没有任何效果。
static List<string> sessions = new List<string>();
static object sessionLock = new object();
void Application_SessionStart()
{
lock (sessionLock) {
sessions.Add(Session.SessionID);
}
}
void Application_SessionEnd()
{
lock (sessionLock) {
sessions.Remove(Session.SessionID);
}
}
if (HttpContext.Current.Response.Cookies.Count > 0)
{
foreach (string s in HttpContext.Current.Response.Cookies.AllKeys)
{
if (s == FormsAuthentication.FormsCookieName || s.ToLower() == "asp.net_sessionid")
{
HttpContext.Current.Response.Cookies[s].Secure = HttpContext.Current.Request.IsSecureConnection;
}
}
}