B
bebop
HI
I'm using Forms-based Authentication and trying out the
example from the book: "ASP.NET Professional Secrets"
after downloading the c# code there was no code for
chapter 15
Can anyone provide the code for chapter 15 and what it
includes?
I tried entering the code from the chapter by hand but I
can't get the program to work.
code from book:
<%@ Page language="C#"%>
<script runat = "server">
void btnLogin_Click(Object sender, EventArgs e) {
if (txtUserName.Value == "User" &&
txtPassword.Value == "Password")
{
FormsAuthentication.RedirectFromLoginPage
(txtUserName.Value, chkSaveCookie.Checked);
}
else
{
divMessage.InnerText = "Invalid user name or
password";
}
}
</script>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<form id="frmLogin" method="post" runat="server">
User Name: <input type="text" id="txtUserName"
name="txtUserName" runat="server">
</p>
Password: <input type="password" name="txtPassword"
id="txtPassword" runat="server">
<p/>
<input type="checkbox" name="chkSaveCookie"
id="chkSaveCookie" runat="server">Save my state
<p/>
<input type="button" name="btnLogin" runat="server"
onserverclick="btnLogin_Click" value="Login">
<p/>
<div runat="server" id="divMessage"></div>
</form>
</body>
</html>
also books mentions to do the following in the Web.Config
file:
set the mode attribute to Forms and provide a loginUrl
<authentication mode="Forms">
<forms name="WileyAuth" loginUrl="LoginPage.aspx"
path="/"> </forms>
and add a location element as well:
<location path="ProtectedPage.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
Any help on Forms-based Authentication would be
appreciated.
bebop
I'm using Forms-based Authentication and trying out the
example from the book: "ASP.NET Professional Secrets"
after downloading the c# code there was no code for
chapter 15
Can anyone provide the code for chapter 15 and what it
includes?
I tried entering the code from the chapter by hand but I
can't get the program to work.
code from book:
<%@ Page language="C#"%>
<script runat = "server">
void btnLogin_Click(Object sender, EventArgs e) {
if (txtUserName.Value == "User" &&
txtPassword.Value == "Password")
{
FormsAuthentication.RedirectFromLoginPage
(txtUserName.Value, chkSaveCookie.Checked);
}
else
{
divMessage.InnerText = "Invalid user name or
password";
}
}
</script>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<form id="frmLogin" method="post" runat="server">
User Name: <input type="text" id="txtUserName"
name="txtUserName" runat="server">
</p>
Password: <input type="password" name="txtPassword"
id="txtPassword" runat="server">
<p/>
<input type="checkbox" name="chkSaveCookie"
id="chkSaveCookie" runat="server">Save my state
<p/>
<input type="button" name="btnLogin" runat="server"
onserverclick="btnLogin_Click" value="Login">
<p/>
<div runat="server" id="divMessage"></div>
</form>
</body>
</html>
also books mentions to do the following in the Web.Config
file:
set the mode attribute to Forms and provide a loginUrl
<authentication mode="Forms">
<forms name="WileyAuth" loginUrl="LoginPage.aspx"
path="/"> </forms>
and add a location element as well:
<location path="ProtectedPage.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
Any help on Forms-based Authentication would be
appreciated.
bebop