Verify user exits

Posted on 2009-04-27
Last Modified: 2012-05-06
Hi Experts.

I"ve been searching forever and can't seem to find out how to verify that a user exists in 2.0
 I'm using the Authorization/Membership Management and c#

Question by:tenderroni992003
    LVL 41

    Accepted Solution

    If you are using ASP.Net Membership here is one way to find if a UserExists or not.
    Below is sample code:
    You can check othe Membership API methods to see if any other matches your requirements.
    Also the is Roles API you might want to look into if you want to deal with Roles.

     MembershipUser user = Membership.GetUser("YourUserName");
            if (user != null)
             Response.Write("User is null");

    Open in new window


    Author Comment

    I tried the above solution, and it always returns null.

    admin: relevance: 2.0, c#,  microsoft programming

    LVL 41

    Expert Comment

    make sure your membership is working properly.
    i.e. Are you able to create new user and login with that username?
    Please provide more info on what exactly you did and what exactly you are looking for.

    Author Comment

    guro_sami, your solution was absolutely correct!  Thank you!

    I fond my error.  I was getting the string from a text box, but I wasn't converting the textbox text to a string.  I thought that you could stop at textbox.Text, but you actually have to have
    so the following works:  Membership.GetUser(textbox.Text.ToString())
    Go figure.

    Thank you so much!


    Author Closing Comment

    Thank yo so much for all of your wonderful help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now