asp:login w/ ASP.NET 2.0 -- still can't get basic login page to work

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

  1. Sasquatch

    Sasquatch Guest

    I'm still 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. I've got a little better troubleshooting
    information for everyone now. First, here's how I set this stuff up...

    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#" %>
    <html>
    <body>
    Content page!
    </body>
    </html>

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

    <%@ Page Language="C#" %>
    <html>
    <body>
    <form runat="server">
    <asp:Login ID="Login1" runat="server"></asp:Login>
    </form>
    </body>
    </html>

    ....and 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="myuser" />
    <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=password;"
    providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.net>
    <mailSettings>
    <smtp>
    <network
    host="smtp.ourmailserver.net"
    port="25" />
    </smtp>
    </mailSettings>
    </system.net>
    <system.web>
    <compilation debug="false"/>
    <authentication mode="Forms"/>
    <customErrors mode="Off"/>
    </system.web>
    </configuration>

    ....that's it. Any assistance would be greatly appreciated.

    Thanks,
    John
    Sasquatch, Oct 4, 2006
    #1
    1. Advertising

  2. Where is that connection pointing? Is there a database there? If this is an
    exact copy of the web.config, it looks like you haven't adjusted the
    connection string to point directly to the database (it should be an mdf
    file as this is a SqlServer connection).


    --
    Hope this helps,
    Mark Fitzpatrick
    Former Microsoft FrontPage MVP 199?-2006


    "Sasquatch" <> wrote in message
    news:...
    > I'm still 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. I've got a little better troubleshooting
    > information for everyone now. First, here's how I set this stuff up...
    >
    > 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#" %>
    > <html>
    > <body>
    > Content page!
    > </body>
    > </html>
    >
    > ...and here is my code for login.aspx...
    >
    > <%@ Page Language="C#" %>
    > <html>
    > <body>
    > <form runat="server">
    > <asp:Login ID="Login1" runat="server"></asp:Login>
    > </form>
    > </body>
    > </html>
    >
    > ...and 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="myuser" />
    > <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=password;"
    > providerName="System.Data.SqlClient" />
    > </connectionStrings>
    > <system.net>
    > <mailSettings>
    > <smtp>
    > <network
    > host="smtp.ourmailserver.net"
    > port="25" />
    > </smtp>
    > </mailSettings>
    > </system.net>
    > <system.web>
    > <compilation debug="false"/>
    > <authentication mode="Forms"/>
    > <customErrors mode="Off"/>
    > </system.web>
    > </configuration>
    >
    > ...that's it. Any assistance would be greatly appreciated.
    >
    > Thanks,
    > John
    >
    Mark Fitzpatrick, Oct 4, 2006
    #2
    1. Advertising

  3. Sasquatch

    Sasquatch Guest

    I thought the connection was assumed. I thought there was a default
    connection that is set up in machine.config for membership. Likewise,
    there is an aspnetdb.mdf file in the /app_data folder that contains the
    users I set up, passwords hashed, etc. I thought the asp:control would
    just know to look there by default. If not, what do I need to add to
    my web.config? Can you send me an example? Thanks! -John

    Mark Fitzpatrick wrote:
    > Where is that connection pointing? Is there a database there? If this is an
    > exact copy of the web.config, it looks like you haven't adjusted the
    > connection string to point directly to the database (it should be an mdf
    > file as this is a SqlServer connection).
    >
    >
    > --
    > Hope this helps,
    > Mark Fitzpatrick
    > Former Microsoft FrontPage MVP 199?-2006
    >
    >
    > "Sasquatch" <> wrote in message
    > news:...
    > > I'm still 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. I've got a little better troubleshooting
    > > information for everyone now. First, here's how I set this stuff up...
    > >
    > > 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#" %>
    > > <html>
    > > <body>
    > > Content page!
    > > </body>
    > > </html>
    > >
    > > ...and here is my code for login.aspx...
    > >
    > > <%@ Page Language="C#" %>
    > > <html>
    > > <body>
    > > <form runat="server">
    > > <asp:Login ID="Login1" runat="server"></asp:Login>
    > > </form>
    > > </body>
    > > </html>
    > >
    > > ...and 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="myuser" />
    > > <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=password;"
    > > providerName="System.Data.SqlClient" />
    > > </connectionStrings>
    > > <system.net>
    > > <mailSettings>
    > > <smtp>
    > > <network
    > > host="smtp.ourmailserver.net"
    > > port="25" />
    > > </smtp>
    > > </mailSettings>
    > > </system.net>
    > > <system.web>
    > > <compilation debug="false"/>
    > > <authentication mode="Forms"/>
    > > <customErrors mode="Off"/>
    > > </system.web>
    > > </configuration>
    > >
    > > ...that's it. Any assistance would be greatly appreciated.
    > >
    > > Thanks,
    > > John
    > >
    Sasquatch, Oct 4, 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. craig dicker
    Replies:
    1
    Views:
    366
    Peter Rilling
    Jul 10, 2005
  2. Pascal Blanchard
    Replies:
    0
    Views:
    245
    Pascal Blanchard
    Aug 17, 2004
  3. Pascal Blanchard
    Replies:
    1
    Views:
    278
    Pascal Blanchard
    Aug 18, 2004
  4. Xeno Campanoli
    Replies:
    1
    Views:
    342
    James Britt
    Jul 1, 2005
  5. Replies:
    6
    Views:
    82
    Richard Cornford
    May 7, 2006
Loading...

Share This Page