Tuesday, December 14, 2010

How to get session time out value

SessionTimeout.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
Session["FavoritePhone"] = "Nokia E61";
Label1.Text = "Session read...<br />";
Label1.Text += "Session Timeout[Minutes]: " + Session.Timeout;
Label1.Text += "<br />Favorite Phone : " + Session["FavoritePhone"];
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>asp.net session Timeout example: how to get session time out value</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">asp.net session example: Session Timeout</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
ForeColor="CornflowerBlue"
>
</asp:Label>
</div>
</form>
</body>
</html>

No comments: