Results 1 to 10 of 10

Thread: Creating a Web Site with Membership and User Login

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Creating a Web Site with Membership and User Login

    I am taking MSDN's walkthrough on Creating a Web Site with Membership and User Login. I have some free time and am taking a look at some topics I'm not 100% clear on. So this isn't for a live site; just for my own edification.

    I set up a user in the web site administration tool then another one in the CreateUserWizard control. I was surprised that in the control it let me create the 2nd user with the same email id as the 1st so I was looking around at how to prevent this. I found requiresUniqueEmail="true" that goes in web.config, in this block:
    Code:
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
      <providers>
        <add name="SqlProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="SqlServices"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          passwordFormat="Hashed"
          requiresUniqueEmail="true"
          applicationName="MyApplication" />
      </providers>
    </membership>
    Which I believe would be the solution. Is that right? My problem is what do I set all those other attributes to in the block? All I really want is requiresUniqueEmail but it seems I have to specify a connectionstring also but I don't know what this would be. The website is using ASPNETDB.MDF which got created in App_Data after I ran the administration tool for the first time (I believe). So I need to explicitly define a connectionstring to that DB now that I want to require a unique email?

    Thanks.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Re: Creating a Web Site with Membership and User Login

    I tried something, and while the administration tool no longer gave me an error regarding my db connection, there is some kind of an error because it is displaying 0 users when there should be 2...unless it invalidated the two previously created because they have the same email id and now I am saying they can't - is it that smart that it would do that? Or is this connectionstring wrong?
    Code:
    		<add name="LocalSqlServer"
    			 connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
    			 providerName="System.Data.SqlClient"/>
    	</connectionStrings>
    (I did change the connectionstringname in post #1 to LocalSqlServer so it picks up this entry).
    Last edited by MMock; Oct 13th, 2015 at 09:24 AM. Reason: clarification
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Re: Creating a Web Site with Membership and User Login

    I defined my users again. I created "Marlene" in the administration tool. I created "Marlene2" with the wizard, or tried to but this time I got the error I wanted that the email ID is already in use.

    So the only outstanding question at this point is how did the first two users I created get clobbered? Because let's say a website went live and 100 users registered themselves and then someone reported a bug because they never received an email to reset their password because they had made a typo and entered someone else's email but the site let them. So then as the developer I wanted to go enforce unique emails - would the way I did this just now not be the correct way? I mean, I accomplished what I wanted but I am just playing with a walkthrough.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Creating a Web Site with Membership and User Login

    Have you checked the database directly, using the SQL Server Explorer within Visual Studio, or how are you verifying that the users aren't there?

    Is it possible that originally you were using a different database? From my experience, users don't simply get deleted as a result of entering an incorrect/duplicate email address through the CreateUserWizard, so I don't think you have anything to worry about there.

    Keep in mind as well, the User Administration Tool is not something that you are going to be able to ship with your site when it goes into production. If this is something that you are going to need, you are likely going to have to create the administration pages yourself.

    Gary

  5. #5

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Re: Creating a Web Site with Membership and User Login

    Thanks, Gary. You probably know now from reading my message to you, that this is just another of my asides while things are slow on my real project. I will check into actually querying the database to see what data there is, as soon as I have some more coffee/breakfast and wake up...
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Creating a Web Site with Membership and User Login

    There is an easy way to make your emails unique in the asp.net membership db.
    You will go to the "dbo.aspnet_membership" table, open up the indexes and select properties on the "aspnet_Membership_index" then select the "LoweredEmail" and click on "unique" . Remember this must be done before any duplicate emails have been created to the database, or you will have to delete-rename them first.
    Also note that MS a$$es depricated the membership database in VS2013. It is still there but you will have to go through IIS to manipulate it,

    P.S. Hi Gary long time no see
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    Re: Creating a Web Site with Membership and User Login

    Quote Originally Posted by sapator View Post
    P.S. Hi Gary long time no see
    OMG - I sent Gary a private email yesterday because it had been such a long time!

    I guess he made it up to me by answering my thread .
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  8. #8
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Creating a Web Site with Membership and User Login

    Quote Originally Posted by sapator View Post
    Also note that MS a$$es depricated the membership database in VS2013. It is still there but you will have to go through IIS to manipulate it
    What exactly do you mean by this? What does hte Membership Provider and associated database have to do with IIS? Are you talking about the aspnetdb.mdf file?

    Quote Originally Posted by sapator View Post
    P.S. Hi Gary long time no see
    Indeed, it has been a long time

  9. #9
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Creating a Web Site with Membership and User Login

    Quote Originally Posted by gep13 View Post
    What exactly do you mean by this? What does hte Membership Provider and associated database have to do with IIS? Are you talking about the aspnetdb.mdf file?



    Indeed, it has been a long time
    I mean that there is no ASP.NET configuration -Web Site Administration Tool option, in order to use it you must go through command prompt IIS commands. The idea of hiding something really good and not removing it is really stupid. I mean if you don't want people to use the administration tool then fine, remove it completely, don't just cover it up with dirt.
    MS is doing really idiotic things lately. Window 8.1 , mobile phones, MVC. Some people were applauding here about those things but the company itself is rushing on removing them.
    I was trying to go completely on php but my current position will not give me that option. At least i can use VB.NET that i prefer over C# (not basing C#, it's a matter of taste here).
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  10. #10
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Creating a Web Site with Membership and User Login

    Quote Originally Posted by sapator View Post
    I mean that there is no ASP.NET configuration -Web Site Administration Tool option, in order to use it you must go through command prompt IIS commands.
    Ok, so we are talking about the same thing This is what I mentioned above:

    Quote Originally Posted by gep13 View Post
    Keep in mind as well, the User Administration Tool is not something that you are going to be able to ship with your site when it goes into production. If this is something that you are going to need, you are likely going to have to create the administration pages yourself.
    Yes, this is a definitely a draw back, and adds some additional work to anyone looking to take advantage of the ASP.NET Membership Provider. Even with the new ASP.NET Identity Provider, there is still no out of the box Administration Page. The guys over at ThinkTecture have created something called IdentityManager which tries to fit this gap, but this also has some limitations, but it is certainly better than nothing.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width