I have typed the following code, and also downloaded the code and get the same results with both.
When I navigate to the default.aspx page the login.aspx page displays first. When I type in an invalid name and password I get the expected prompts. But when I type in the correct name and password, the login page re-displays with the name filled out and the password text box blank with nor error prompts. The default.aspx page is never displayed.
Here the 3 files
web.config
<configuration>
<system.web>
<authentication mode="Forms">
<forms name=".WroxDemo" loginUrl="login.aspx"
protection="All" timeout="60" />
</authentication>
<machineKey validationKey="AutoGenerate"
decryptionKey="AutoGenerate" validation="SHA1"/>
<authorization>
<deny users="?" />
</authorization>
<customErrors mode="Off"/>
</system.web>
</configuration>
login.aspx
<%@ Import Namespace="system.Web.Security " %>
<html>
<head>
<script language="
VB" runat="server">
Sub Login_Click(Src as Object, E as EventArgs)
If Page.IsValid Then
if txtEmail.Text = "Wrox" and txtPwd.Text = "MyPass" Then
FormsAuthentication.RedirectFromLoginPage(txtEmail .Text,true)
else
lblLoginMsg.Text = "Use Wrox as user name and password as " & _
"MyPass. Please try again."
end if
End If
End Sub
</script>
</head>
<body>
<form runat="server">
<h1>Using Form based Authentication<BR>with Pre-defined Credentials</h1>
Users Name:
<asp:textbox id="txtEmail" runat="server" />
*
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
Display="Dynamic"
ErrorMessage="Login name can't be empty."
runat="server"/>
Password:
<asp:textbox TextMode="Password" id="txtPwd" runat="server" />
*
<asp:RequiredFieldValidator
ControlToValidate="txtPWD"
Display="Dynamic"
ErrorMessage="Password can't be empty."
runat="server"/>
<asp:Label
id="lblLoginMsg"
ForeColor="Red"
Font-Name="Verdana";
Font-Size="10"
runat="server" />
<asp:button
id="btnLogin"
Text="Login"
OnClick="Login_Click"
runat=Server />
</form>
</body>
</html>
default.aspx
<%@ Import Namespace="system.Web.Security " %>
<html>
<head>
<script language="
VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
lblUser.Text = "
Your usr name is: " & User.Identity.Name
lblType.Text = "
Your Authentication type is: " & _
User.Identity.AuthenticationType
End Sub
Sub Logout_click(Src As Object, E as EventArgs)
FormsAuthentication.SignOut()
Server.Transfer("login.aspx)
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:label id="lblUser" runat="server"/>
<asp:label id="lblType" runat="server"/>
<asp:Button text="Logout" OnClick="Logout_Click" runat="server"/>
</form>
</body>
</html>
The IIS server is installed locally on a WIN2K professional desktop with Visual studio.net installed. (to get the .NET framework)
I used the IIS MMC New Virtual Folder wizard to create the virtual folder accepting all of the defaults.
any help you can provide is much appreciated!
Bill