Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net web应用程序中的Sql server会话模式_C#_Asp.net_Asp.net Mvc_Sql Server 2008_Asp.net Mvc 4 - Fatal编程技术网

C# asp.net web应用程序中的Sql server会话模式

C# asp.net web应用程序中的Sql server会话模式,c#,asp.net,asp.net-mvc,sql-server-2008,asp.net-mvc-4,C#,Asp.net,Asp.net Mvc,Sql Server 2008,Asp.net Mvc 4,我有两个项目解决方案。第一个是asp.net(.aspx)web应用程序。第二个是mvc(.cshtml)web应用程序。第一个应用程序具有指向第二个应用程序的重定向链接。用户仅通过第一个应用程序登录。我想使用sql server会话模式在sqlserver中存储用户的登录详细信息和页面详细信息。 任何建议都会有帮助。谢谢 编辑 我尝试从中使用sql server会话模式。 会话值存储在ASPState数据库中。如何检查会话是否过期以及是否使用过期会话中的值 以下代码检查会话是否过期 prote

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

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

以下代码检查会话是否过期

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
                    }
                }
            }
        }
    }

以下代码检查会话是否过期

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
                    }
                }
            }
        }
    }