Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6605735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:19:11+00:00 2026-05-25T19:19:11+00:00

i log users into .net using straightforward .net authentication: if ( Membership.ValidateUser( user, passwd

  • 0

i log users into .net using straightforward .net authentication:

if ( Membership.ValidateUser( user, passwd ) )

works fine. hot on the heels of that, i try to get the user name:

Membership.GetUser().UserName

sometimes this will return an invalid object. sometimes not.
i cannot seem to detect a pattern as to which is which.

for example, a user logs in with a valid role in the system as ‘root’/’password’.
the ValidateUser() call succeeds, but Membership.GetUser().UserName returns an invalid object.
2 seconds later, do the same exact thing again, and both the validate and the GetUser() succeed.

any ideas?


.. edit 1 ..
here’s how i use the username:

Roles.GetRolesForUser( Membership.GetUser().UserName ); 

when i swap in System.Environment.UserName, the roles list comes back empty.

if i leave it as is and i set the auth cookie using ‘true’ as my second argument, it works fine.

FormsAuthentication.SetAuthCookie( user, true );

if i use HttpContext.Current.User.Identity.Name, the roles list is fine with the auth cookie set to true or false.

now, i understand the issue about performance. this is important to me. but i also need to ensure the application functions correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:19:11+00:00Added an answer on May 25, 2026 at 7:19 pm

    Why can’t you use

    HttpContext.Current.User.Identity.Name
    

    ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing vb.net code to log a user into my application using SQL
I am writing vb.net code to log a user into my application using SQL
I've been having trouble getting my ASP.NET application to automatically log users into the
When a user log into my asp.net site I use the following code: FormsAuthentication.RedirectFromLoginPage(userid,
I have a internal website that users log into. This data is saved as
I'm using the ASP.NET/C# Login control and that entire authentication and authorization system. I
I'm currently trying to make a log in for facebook users into my WPF
I'm currently using an SqlDataSource in ASP.NET/C# to let users insert, delete and update
I have used facebook to allow users to log into a site. The page
I have an ASP.NET application running on IIS 7 and using Windows Authentication. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.