Export (0) Print
Expand All

Default.aspx File

.NET Framework 1.1

The Default.aspx file, shown below, is the default requested, protected resource. It is a simple file that displays the string Hello plus the user's stored e-mail name if a valid cookie is transmitted with the request. If a cookie is not transmitted with the request, ASP.NET automatically redirects the client to the Logon.aspx page. Default.aspx also includes a Signout button that deletes the cookie from the client

<script runat=server>
    private void Page_Load(Object Src, EventArgs e) 
    {
        Welcome.InnerHtml = "Hello, " +   
            Server.HtmlEncode(User.Identity.Name);
    }
    private void Signout_Click(Object sender, EventArgs e) 
    { 
        FormsAuthentication.SignOut();
        Response.Write("Logged out - cookie deleted.");
    }
</script>

<body>
<h3><font face="Verdana">Forms Authentication Example</font></h3>
<span id="Welcome" runat=server/>
<form runat=server>
    <input type="submit" OnServerClick="Signout_Click" 
           Value="Signout" runat="server"/><p>
</form>
</body>
</html>

See Also

ASP.NET Web Application Security | Forms Authentication Using an XML Users File

Show:
© 2014 Microsoft