Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 6th, 2009, 02:04 AM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default interesting error. one time logins...

okay. i wrote my login info down in notepad so i would make sure i wasnt screwing up and forgetting my login info.

before when i was debugging i usually made a new account each time i logged in. i tried logging in on the same one TWICE and couldnt do it. it was that message on the login control saying "you cant log in" or something...

long story short, how do i make it so i can log in again? i mean i havent planned my site but im sure people will eventually want to see it twice... :P
 
Old February 6th, 2009, 09:19 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Did you move or deploy your application to a different server or path at some point?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old February 27th, 2009, 03:47 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

yes i did. from folder a to b.
 
Old February 27th, 2009, 08:25 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default hope a code example helps

actually i put the database file from my computer to the App_Data folder on my webserver... then the people that run the server said all DB files must be in the DB folder, not App_Data. so i reuploaded the db file to the database folder and i got my connection string connecting to that one now.

but i am completely clueless about why i can only log in once... (at registration) it wont let me back in...
 
Old March 2nd, 2009, 02:49 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

This may explain why you lose the ability to log in after you move the database.

http://weblogs.asp.net/scottgu/archi...Providers.aspx
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old March 4th, 2009, 03:40 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

thanks Lee that page was helpful. now i know what im looking for, i just have to figure out how to get it. (my flash drive is at home and im on a school computer so i cant really do much from here).

anyways, thanks again
 
Old March 4th, 2009, 11:32 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

hey Lee. maybe you can take a loook at this with me... its kind of a bit of code here but it is in pretty "manageable" chunks. and not all of it is really neccessary to show but i do anyways in case someone decides to give constructive criticism. anyways my problem here is:

1) After registering, the register page reloads with blank text fields instead of redirecting me to my profile page.

2) i cant log in with the created user account (the new username shows up in my member list though) the only reason i can log in at all is because of the user account i defined in the web config file.

if i get a reply on this giant post (its my gift to whoever needs to make a login procedure on their page) my thanks in advance

******************
WEB.CONFIG |
******************

Overview:
1) Defined ConnectionString:myConnection0&&myConnection1
2) Defined Provider

Code:
 
WEB CONFIG
<connectionStrings>
      <add name="myconnection0" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\MemberSites\MemberSites_AspSpider_Ws\iceman90289\database\ASPNETDB.MDF;Integrated Security=True;User Instance=True" />
      <add name="myconnection1" connectionString="Data Source=.\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=iceman90289_ASPNETDB"/>
  </connectionStrings>
 <roleManager enabled="true">
  </roleManager>
 <membership defaultProvider="MyMembership">
  <providers>
   <add name="MyMembership" minRequiredNonalphanumericCharacters="0" type="System.Web.Security.SqlMembershipProvider"
                                       connectionStringName="myconnection0" requiresQuestionAndAnswer="false" requiresUniqueEmail="True"
                                       applicationName="/iceman90289" />
   </providers>
  </membership>
***********************
REGISTER.ASPX |
***********************

Overview:
1) Created Custom Register Form
2) Creates a profile on a usertable

Code:
 
<script runat="server">
    protected void AddUserToProfile(object sender, EventArgs e)
    {
        CreateUserProfile(
            ((TextBox)CreateUserWizard1.FindControl("UserName")).Text,
            ((TextBox)CreateUserWizard1.FindControl("txtFirstName")).Text,
            ((TextBox)CreateUserWizard1.FindControl("txtLastName")).Text,
            ((TextBox)CreateUserWizard1.FindControl("Password")).Text,
            ((TextBox)CreateUserWizard1.FindControl("Email")).Text,
            ((DropDownList)CreateUserWizard1.FindControl("ddlQuestion")).SelectedValue,
            ((TextBox)CreateUserWizard1.FindControl("txtAnswer")).Text);
    }
 
    protected void CreateUserProfile(string userName, string firstName, string lastName, string password, 
        string email, string question, string answer)
    {
        string constring = WebConfigurationManager.ConnectionStrings["UserProfiles"].ConnectionString;
        SqlConnection con = new SqlConnection(constring);
        SqlCommand cmd0 = new SqlCommand("CREATE TABLE UserProfiles (UserName varchar(30), FirstName varchar(30), LastName  varchar(30),Password  varchar(30),Email     varchar(30),Question  varchar(30),Answer    varchar(30))");
        using (con)
        {
            con.Open();
            cmd0.ExecuteNonQuery();
            con.Close();
        }
 
        SqlCommand cmd = new SqlCommand("INSERT INTO UserProfiles(UserName, FirstName, LastName, Email, Question, Answer) VALUES(@UserName, @FirstName, @LastName, @Email, @Question, @Answer"); 
        cmd.Parameters.AddWithValue("@UserName", userName);
        cmd.Parameters.AddWithValue("@Password", lastName);
        cmd.Parameters.AddWithValue("@FirstName", firstName);
        cmd.Parameters.AddWithValue("@LastName", lastName);
        cmd.Parameters.AddWithValue("@Email", email);
        cmd.Parameters.AddWithValue("@Question", question);
        cmd.Parameters.AddWithValue("@Answer", answer);
        using (con)
        {
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
        }
    }
</script>
 
<asp:CreateUserWizard
        id="CreateUserWizard1"
        RequireEmail="true"
        AutoGeneratePassword="false"
        OnCreatedUser="AddUserToProfile"
        ContinueButtonText="Proceed" CreateUserButtonText="Create Profile" 
        runat="server" BorderStyle="Outset" BorderWidth="2" 
            CompleteSuccessText="Your account is good to go alright! chaha!">
        <WizardSteps>
            <asp:CreateUserWizardStep>
            <ContentTemplate>
            <h1>Register Here</h1>
            <asp:Label
                    id="lblUserName"
                    Text="User Name: "
                    AssociatedControlID="UserName"
                    Runat="server" />
                <asp:TextBox
                    id="UserName"
                    runat="server" />
                <br />
                <asp:Label
                    id="lblPassword"
                    Text="Password: "
                    AssociatedControlID="Password"
                    Runat="server" />
                <asp:TextBox
                    id="Password"
                    runat="server" />
                <br />
            <br />
                <asp:Label
                    id="lblFirstName"
                    Text="First Name"
                    AssociatedControlID="txtFirstName"
                    Runat="server" />
                <asp:TextBox
                    id="txtFirstName"
                    runat="server" />
                <br />
                <asp:Label
                    id="Label2"
                    Text="Last Name"
                    AssociatedControlID="txtLastName"
                    Runat="server" />
                <asp:TextBox
                    id="txtLastName"
                    runat="server" />
                <br />
                <asp:Label
                    id="Label3"
                    Text="Email"
                    AssociatedControlID="Email"
                    Runat="server" />
                <asp:TextBox
                    id="Email"
                    runat="server" />
                <br /><br />
                <asp:Label
                    id="Label4"
                    Text="Security Question: "
                    AssociatedControlID="ddlQuestion"
                    Runat="server" />
                <asp:DropDownList
                    id="ddlQuestion"
                    runat="server">
                    <asp:ListItem
                        Text="Enter Pet Name"
                        Value="Pet Name" />
                    <asp:ListItem
                        Text="Enter Favorite Color"
                        Value="Favorite Color" />
                </asp:DropDownList>
                <br /> <br />
                <asp:Label
                    id="lblAnswer"
                    Text="Security Answer"
                    AssociatedControlID="txtAnswer"
                    runat="server" />
                <asp:TextBox
                    id="txtAnswer"
                    runat="server" />
                    <hr />
            </ContentTemplate>
            </asp:CreateUserWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>
*******************
LOGIN.ASPX |
*******************

Overview:
* Simple login control.

Code:
 
<script runat="server">
 
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        string userName = Login1.UserName;
        string password = Login1.Password;
        e.Authenticated = FormsAuthentication.Authenticate(userName, password);
    }
 
</script>
<asp:Login     ID="Login1" 
                   runat="server" 
                   OnAuthenticate="Login1_Authenticate"
                   BackColor="#F7F6F3" 
                   BorderColor="#E6E2D8" 
                   BorderPadding="4" 
                   BorderStyle="Solid" 
                   BorderWidth="1px" 
                   CreateUserText="Register" 
                   CreateUserUrl="~/Register.aspx" 
                   Font-Names="Verdana" 
                   Font-Size="0.8em" 
                   ForeColor="#333333" 
                   Height="200px" 
                   TitleText="Sign In" 
                   Width="415px" 
                   VisibleWhenLoggedIn="False"
                   MembershipProvider="MyMembership" />
 
Old March 5th, 2009, 03:14 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

ok dparsons told me to take out the OnAuthenticate event.

so i did, now it works and i have a huge chunk of code that is pretty much free to the world now haha

enjoy it guys thats why its there
 
Old March 5th, 2009, 03:38 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I should point out the reason why he does not need to handle the Authenticate event is because he is not preforming any specialized user validation therefore you can leave everything up to the Membership provider.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
iceman90289 (March 5th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
An interesting question iPagan BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 February 13th, 2007 05:31 PM
Photo Album - interesting error abel714 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 8 January 4th, 2007 06:29 PM
Interesting Problem prasanta2expert ASP.NET 1.0 and 1.1 Basics 1 October 16th, 2006 08:14 PM
How shall I make the game interesting? flash2004 Need help with your homework? 0 June 11th, 2006 10:17 PM
Interesting Error kanchan_b XSLT 1 February 1st, 2006 03:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.