asp.net c# examples code for web developers.

Get whether session was created only for current request or not in asp.net

Get whether the session was created only for the current request or not
IsNewSession.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["ZipCode"] = "12345";
        Label1.Text = "Session read<br />";
        Label1.Text += "Session IsNewSession?: " + Session.IsNewSession;
        Label1.Text += "<br />Zip Code :" + Session["ZipCode"];
        
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net session IsNewSession example: how to get whether the session was created only for the current request or not</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Blue">asp.net session example: Session IsNewSession?</h2>
        <asp:Label 
            ID="Label1" 
            runat="server" 
            Font-Size="Large"
            ForeColor="OrangeRed"
            >
        </asp:Label>
    </div>
    </form>
</body>
</html>
More asp.net examples
Copyright © 2008-2015 | asp.net c# examples | asp-net-example.blogspot.com | Author Saiful Alam