Frazzle
Frazzle

Reputation: 11

ASP.net Linq getting logged in user to filter a linq query

Hi I am using sqlMembershipProvider and I tried to get at the user object to filter a linq query. But i cant seem to find the UserID in this object.

here's my code:

var query =  (from b in db.Builders where b.UserID==b.UserID????ID select b).ToList();

Upvotes: 1

Views: 470

Answers (1)

Jason Meckley
Jason Meckley

Reputation: 7591

the user is associated with the request, so you can pull the username from there

HttpContext.Current.User.Identity.Name;

If you can reference the current context without using the static gateway HttpContext.Current, that would be event better.

Upvotes: 1

Related Questions