I have a users table and a company table, Im using linqtosql classes
Whats the best way to get the id of the user thats currently logged on so that I can find the company he works for??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Ya it depends what your using. If your using your own custom table you could go
User.Identity.Nameto get the name from the logged in user.Then do a search in your users table(at this point you could grab the userId from the table and use it to look up all the other tables by userId). Of course if you have duplicate user names then your going to have to add some more data to the cookie you store for your user to help figure out the duplicate name.
If your using asp.net membership then they got built in methods for you to use.
http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser_members.aspx