<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<sessionState timeout="1" mode="InProc" cookieless="false" >
</sessionState>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="1"/>
</authentication>
我创建了一个会话,如果用户进行身份验证这样会话变量
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
string name = HttpContext.Current.User.Identity.Name.ToString();
Session["username"] = name;
}
然后我检查,如果会话仍然像这里一样退出
if (Session["username"] == null)
Response.Redirect("SessionExpired.aspx");
else
Response.Write("session still exist");
**问题:** 1分钟后会话不变为空,用户始终登录任何帮助
这是代码:
Welcome to ASP.NET! test1
<p>
To visit test2 go to<asp:LinkButton ID="LinkButton1" runat="server"
onclick="LinkButton1_Click">here</asp:LinkButton>
</p>
<asp:Label ID="msg" runat="server" Text=""></asp:Label>
在服务器端
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
string name = HttpContext.Current.User.Identity.Name.ToString();
Session["username"] = name;
if (Session["username"] == null)
Response.Redirect("~/SessionExpired.aspx");
else
msg.Text = "session still exist the session will be timedout after "+Session.Timeout+ "min";
}
else
Response.Write("please login");
}
你甚至读过他的问题吗? mode =“InProc”!!! – Baz1nga 2012-03-31 08:32:32
是的。在我发布的用户链接也改变了模式“inproc” – TRR 2012-03-31 08:35:15
这是正确的,在这里,他不是说他得到它后,改变它的InProc罚款..他面临的问题,同时使用它.. – Baz1nga 2012-03-31 08:37:21