Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Can't create simple login page using asp:login control

Reply
Thread Tools

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

 
 
Sasquatch
Guest
Posts: n/a
 
      10-03-2006
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+CLTPK4mfkrCVRYbqnZLFzetUkCTbticDbHaHz HE=" />
<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!!!

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      10-03-2006
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!
*************************************************
"Sasquatch" <> wrote in message
news: ups.com...
> 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+CLTPK4mfkrCVRYbqnZLFzetUkCTbticDbHaHz HE=" />
> <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!!!
>



 
Reply With Quote
 
 
 
 
Sasquatch
Guest
Posts: n/a
 
      10-03-2006
Cowboy (Gregory A. Beamer) wrote:
> 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=mai ndb;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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
login page stays on login page Shannon ASP .Net 2 01-09-2008 10:51 PM
How to create an instance of user control in a class(simple) file notin Page class file? chandan ASP .Net 2 12-03-2007 06:01 AM
Can login with Login Control ad ASP .Net 9 08-31-2006 05:46 PM
Keep getting "Your login attempt was not successful...." from <asp:Login> control - but it works on Dev box. Jack ASP .Net Web Controls 1 07-16-2006 06:08 AM
How to center login button in Login control? ike2010 ASP .Net 0 11-15-2005 09:13 PM



Advertisments