2013-01-07 188 views
1

我有两个项目解决方案。第一个是与asp.net(.aspx)web应用程序。第二个是mvc(.cshtml)web应用程序。第一个应用程序有第二个应用程序的重定向链接。用户只能通过第一个应用程序登录。我想使用sql server会话模式将用户的用户登录详细信息和用户的页面详细信息存储在sqlserver中。
任何建议都会有帮助。由于asp.net web应用程序中的Sql服务器会话模式

编辑
我尝试使用SQL Server会话模式从Link。 会话值存储在ASPState数据库中。如何检查会话是否已过期以及是否从已过期的会话中使用这些值。 ?

回答

1

以下代码检查会话过期。

protected void Page_Init(object sender, EventArgs e) 
    { 
     if (Context.Session != null) 
     { 
      if (Session.IsNewSession) 
      { 
       HttpCookie newSessionIdCookie = Request.Cookies["ASP.NET_SessionId"]; 
       if (newSessionIdCookie != null) 
       { 
        string newSessionIdCookieValue = newSessionIdCookie.Value; 
        if (newSessionIdCookieValue != string.Empty) 
        { 
         // This means Session was timed Out and New Session was started 
         // Do whatever you want 
        } 
       } 
      } 
     } 
    } 
相关问题