http://www.aspforums.net/Threads/551777/how-to-refresh-a-session-without-showing-any-message/
That was my last question . now continuing it
Still there will be need of url in ajax method if i put javascript in site.master.cs . As what i have understood from Azim reply he mean to say that my
site.master.cs will be like this :
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["Prefix"].ToString().Trim() == "sys_admin")
{
UserNameMasterLabel.Text = Session["UserName"].ToString().Trim() + " (ADMIN)";
}
else
{
UserNameMasterLabel.Text = Session["UserName"].ToString().Trim();
}
Session["Name"] = "BSD";
SessionStateSection section = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
Page.ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert", "SessionExpireAlert(" + timeout + ");", true);
}
catch (Exception a)
{
}
}
and site.master will be like this :
<script type="text/javascript">
var interval;
var settimeout;
var newTimeout;
$(function () {
});
function SessionExpireAlert(timeout) {
var seconds = timeout / 1000;
clearInterval(interval);
interval = setInterval(function () {
seconds--;
document.getElementById("seconds").innerHTML = seconds;
}, 1000);
settimeout = setTimeout(function () {
//window.location = "Expired.aspx";
$.ajax({
type: "POST",
url: "DailyLog.aspx/RefreshSession",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
newTimeout = r.d;
SessionExpireAlert(newTimeout);
},
error: function (r) {
alert(r.d);
}
});
clearTimeout(settimeout);
}, timeout);
}
</script>
and i have to put next method in DailyLog.aspx page ? like this
System.Web.Services.WebMethod(EnableSession = true)]
public static int RefreshSession()
{
HttpContext.Current.Session["Name"] = "BSD";
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.Config");
SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");
int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
return timeout;
}
? But i have several pages in my website , by doing the above story will it work for Builder.aspx ? or any other page rather than dailylog.aspx ? If no then what to do ?