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