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??
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??
Ya it depends what your using. If your using your own custom table you could go User.Identity.Name
to 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