protected void Page_Load(object sender, EventArgs e)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
Session["User"] = "Authenticated";
Session["Username"] = HttpContext.Current.User.Identity.Name;
Response.Redirect("HomePage.aspx");
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
int recordExistCount = fc.Authenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim());
if (recordExistCount == 1)
{
Session["User"] = "Authenticated";
Session["Username"] = txtUsername.Text.Trim();
fc.IsOnlineRecord(Session["Username"].ToString(),true);
var ticket = new FormsAuthenticationTicket(2,Session["username"].ToString(),DateTime.Now,DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), true,"",FormsAuthentication.FormsCookiePath);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
{
HttpOnly = FormsAuthentication.RequireSSL,
Path = FormsAuthentication.FormsCookiePath,
Domain = FormsAuthentication.CookieDomain
};
Response.Cookies.Add(cookie);
Response.Redirect("HomePage.aspx");
}
<authentication mode="Forms">
<forms loginUrl="LoginPage.aspx"
protection="All"
timeout="60"
name=".ASPXAUTH"
path="/"
requireSSL="false"
slidingExpiration="true"
defaultUrl="HomePage.aspx"
cookieless="UseDeviceProfile"
enableCrossAppRedirects="false"/>
</authentication>
我的页面在闲置超过10分钟后超时。我想知道出了什么问题?
答案 0 :(得分:0)
可能是您的会话超时,而不是表格。您是否在Web.Config中设置了会话超时?这可以在sessionState元素中完成(在system.web元素内部)
点击此链接了解详情:http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=VS.100%29.aspx