1

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

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

4

1 回答 1

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
                    }
                }
            }
        }
    }
于 2013-01-07T12:04:55.537 回答