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

Discussion in 'ASP .Net' started by Sasquatch, Oct 3, 2006.

  1. Sasquatch

    Sasquatch Guest

    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!!!
     
    Sasquatch, Oct 3, 2006
    #1
    1. Advertising

  2. 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:...
    > 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!!!
    >
     
    Cowboy \(Gregory A. Beamer\), Oct 3, 2006
    #2
    1. Advertising

  3. Sasquatch

    Sasquatch Guest

    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=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!
     
    Sasquatch, Oct 3, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan
    Replies:
    1
    Views:
    5,413
    Christophe Gijbels
    Jan 4, 2004
  2. ad

    Can login with Login Control

    ad, Aug 28, 2006, in forum: ASP .Net
    Replies:
    9
    Views:
    956
    Tim_Mac
    Aug 31, 2006
  3. Sasquatch
    Replies:
    2
    Views:
    479
    Sasquatch
    Oct 4, 2006
  4. chandan
    Replies:
    2
    Views:
    773
    chandan
    Dec 3, 2007
  5. Shannon

    login page stays on login page

    Shannon, Jan 9, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    552
    Shannon
    Jan 9, 2008
Loading...

Share This Page