I'm having trouble creating a simple login page using the asp:login
control. I followed some instructions in a WROX book, "Beginning
ASP.NET 2.0," and the instructions are very straight forward, but it
won't work for me. Here's what I did.
1. Created a new folder named "testlogin"
2. Turned that folder into an application using the IIS properties
3. Created two new web form pages, /testlogin/default.aspx and
/testlogin/login.aspx
4. In Visual Web Developer 2005 Express, I clicked the "Website" menu
and selected "ASP.NET Configuration." I used this to add a user
"myuser" and to restrict the /testlogin directory to allow myuser and
deny anonymous users.
5. In Visual Web Developer 2005 Express, I opened login.aspx and
dropped a login control onto the page.
6. Now when I try to go to /testlogin/default.aspx, I get redirected
to /testlogin/login.aspx like I would expect.
7. But when I try to log in, it always fails, giving me the default
"Your login attempt was not successful. Please try again." message.
Here is my code.
First, here is my code for default.aspx...
<%@ Page Language="C#" MasterPageFile= "~/MasterMain.mast er" %>
<asp:Content ID="Content1" ContentPlaceHol derID="ContentH ead"
Runat="Server">
<title>Main Page</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHol derID="ContentM ain"
Runat="Server">
This is a page with content!
</asp:Content>
....and here is my code for login.aspx...
<%@ Page Language="C#" MasterPageFile= "~/MasterMain.mast er" %>
<asp:Content ID="Content1" ContentPlaceHol derID="ContentH ead"
Runat="Server">
<title>Log In</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHol derID="ContentM ain"
Runat="Server">
<div id="WebResource s">
<div class="BoxTop">
<h1>Intranet Log In</h1>
</div>
<div class="BoxBotto m" style="text-align: center;">
<asp:Login ID="Login1" runat="server"> </asp:Login>
</div>
</div>
</asp:Content>
....and here is the code for MasterMain.mast er...
<%@ Master Language="C#" %>
<script runat="server">
protected void Page_Load(Objec t Src, EventArgs E)
{
// ADD HEADER FOR P3P PRIVACY COMPLIANCE
Response.AddHea der("P3P","poli cyref=\"http://www.mysite.com/w3c/p3p.xml\",
CP=\"CURa ADMa DEVa TAIa CONi TELi OUR IND DSP NON COR\"");
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="verify-v1"
content="rjt+CL TPK4mfkrCVRYbqn ZLFzetUkCTbticD bHaHzHE=" />
<link href="/style.css" rel="stylesheet " type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="P3Pv1" href="http://www.mysite.com/w3c/p3p.xml" />
<asp:ContentPla ceHolder ID="ContentHead "
runat="server"> </asp:ContentPlac eHolder>
</head>
<body>
<form runat="server">
<asp:ContentPla ceHolder ID="ContentMain "
runat="server"> </asp:ContentPlac eHolder>
</form>
</body>
</html>
Somebody please help. This is very frustrating.
Thanks!!!