Verify user exits

Posted on 2009-04-27
Medium Priority
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 asp.net 2.0
 I'm using the Authorization/Membership Management and c#

Question by:tenderroni992003
  • 3
  • 2
LVL 41

Accepted Solution

guru_sami earned 2000 total points
ID: 24253897
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

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

admin: relevance:  asp.net 2.0, c#,  microsoft programming

LVL 41

Expert Comment

ID: 24255552
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

ID: 24256043
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

ID: 31575288
Thank yo so much for all of your wonderful help!

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

862 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