一、处理代码:
//请求结束 重写SessionID
protected void Application_EndRequest(object sender, EventArgs e)
{
//重置 ASP.NET_SessionId
if (Request.Url.Host.Contains("localhost") == false)
{
//获取指定ID的cookie 对象,如果不存在则创建
HttpCookie cookie = Response.Cookies.Get("ASP.NET_SessionId");
if (cookie != null && !string.IsNullOrEmpty(cookie.Value))
{
string host = Request.Url.Host;
host = host.Substring(host.IndexOf("."));
cookie.Domain = host;
cookie.Path = "/";
cookie.Value = cookie.Value;
}
else
{
Response.Cookies.Remove("ASP.NET_SessionId");
}
}
}
更多: