What should I write in web config file in asp.net so that my session time is extended. and please tell me the exact location where should I place the code in web config
If you are trying to stop the session from timeing out all the time you can do this rather than increasing the session timeout.
KeepAlive.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KeepAlive.aspx.cs" Inherits="Pages.KeepAlive" %>
<%@ OutputCache Location="None" VaryByParam="None" %>
Keep Alive.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Pages
{
///
/// Page to keep the session alive
///
public partial class KeepAlive : System.Web.UI.Page
{
//- EVENTS ------------------------------------------------------------------------------------------------------------------
#region Events
///
/// Page Load
///
/// object
/// args
protected void Page_Load(object sender, EventArgs e)
{
try
{
//Add refresh header to refresh the page 60 seconds before session timeout
Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60));
}
catch (Exception)
{
throw;
}
}
#endregion Events
//---------------------------------------------------------------------------------------------------------------------------
}
}
Then in your master page create an iFrame that refreshes to keep the session alive