0

如何保持子域之间的会话。我在下面尝试过不锻炼

httpCookies 域=".site.com"

FTP 中的我的文件夹结构

site1 > 主站点一个网站 project.app_code,bin,web.config

      Folder Subdomain1. here i have all files like bin,app_code,web.config etc.

      Folder Subdomain2. here also same.

任何人都可以给我一个想法如何维护这些子域之间的会话。

4

1 回答 1

1

使用这个我希望它对你有用。

protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)

{

  /// only apply session cookie persistence to requests requiring session information



  #region session cookie

  if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState )

  {

    /// Ensure ASP.NET Session Cookies are accessible throughout the subdomains.



    if (Request.Cookies["ASP.NET_SessionId"] != null && Session != null && Session.SessionID != null)

    {

      Response.Cookies["ASP.NET_SessionId"].Value = Session.SessionID;

      Response.Cookies["ASP.NET_SessionId"].Domain = ".know24.net"; // the full stop prefix denotes all sub domains

      Response.Cookies["ASP.NET_SessionId"].Path = "/"; //default session cookie path root         

    }

  }

  #endregion    

}
于 2013-07-20T17:42:03.920 回答