Can't create simple login page using asp:login control

S

Sasquatch

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.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHead"
Runat="Server">
<title>Main Page</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain"
Runat="Server">
This is a page with content!
</asp:Content>

....and here is my code for login.aspx...

<%@ Page Language="C#" MasterPageFile="~/MasterMain.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHead"
Runat="Server">
<title>Log In</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain"
Runat="Server">
<div id="WebResources">
<div class="BoxTop">
<h1>Intranet Log In</h1>
</div>
<div class="BoxBottom" style="text-align: center;">
<asp:Login ID="Login1" runat="server"></asp:Login>
</div>
</div>
</asp:Content>

....and here is the code for MasterMain.master...

<%@ Master Language="C#" %>
<script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
// ADD HEADER FOR P3P PRIVACY COMPLIANCE

Response.AddHeader("P3P","policyref=\"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.dtd">
<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+CLTPK4mfkrCVRYbqnZLFzetUkCTbticDbHaHzHE=" />
<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:ContentPlaceHolder ID="ContentHead"
runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<form runat="server">
<asp:ContentPlaceHolder ID="ContentMain"
runat="server"></asp:ContentPlaceHolder>
</form>
</body>
</html>

Somebody please help. This is very frustrating.

Thanks!!!
 
C

Cowboy \(Gregory A. Beamer\)

Do you have this hooked up to a database (ASP.NET configuration?). I ran
through the code, but I do not see it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
 
S

Sasquatch

Cowboy said:
Do you have this hooked up to a database (ASP.NET configuration?). I ran
through the code, but I do not see it.

What do you mean? I don't think so. I have a connection string in the
web.config for the root application, but this application does not
connect to a database. My understanding is that it is using the
/testlogin/App_Data/ASPNETDB.MDF file, although I have no idea how it
is supposed to know that. I just know that, when I add users using the
ASP.NET Configuration wizard, they get added to the aspnet_Users table
in the ASPNETDB.MDF database. But, like I said, I have no idea how
login.aspx is expected to know to look there. I assumed it's some sort
of default.

Here's a copy of the /testlogin application's web.config...

<?xml version="1.0" encoding="utf-8"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authorization>
<allow users="intranet" />
<deny users="?" />
</authorization>
</system.web>
</configuration>

....and here's a copy of the website's root web.config file...

<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="SqlServerConnectionString"
connectionString="server=.\SQLEXPRESS;database=maindb;User
ID=mainuser;Password=mainpassword;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.net>
<mailSettings>
<smtp>
<network
host="smtp.mymailserver.com"
port="25" />
</smtp>
</mailSettings>
</system.net>
<system.web>
<compilation debug="false"/>
<authentication mode="Forms"/>
<customErrors mode="Off"/>
</system.web>
</configuration>

....does that help? Please, any assistance is greatly appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top