开发者

After login.aspx to default.aspx, then how do i know who just login? == Masterpage.LoginName1.UserName

After login.apsx to default.aspx, then how do i know who just login? I have a login control in masterpage, because i want to do a linq var using logined username as "Where" parameter!

on my master page:

after login.aspx to default.apsx, i have a query in the code-behind file, just want to extract the data for this specific user who justed login.

var query = from uM in db.aspnet_Memberships
                    join uD in db.UserDetails
                    on uM.UserId equals uD.UserId
                    join u in db.aspnet_Users
                    on uM.UserId equals u.UserId
                    join jL in db.JobLists
                    on uM.UserId equals jL.UserId
                    where u.UserName == Masterpage.LoginName1.UserName

                select new { jL.JobId, 
                             jL.JobTitle,
                             jL.Summary,
                             jL.Detail,
                             jL.CompanyName,
                             jL.CompanyEmail,
                             jL.PostDate,
                             uD.City, 
                             uD.State, 
                             uD.Country,
                             u.开发者_如何学运维UserName,
                             jL.IsTop
                };

this gives syntax error where u.UserName == Masterpage.LoginName1.UserName thanks for advance!


User.identity.name or something like that.


Your loginpage can save the username to the session

   this.Session["Usename"] = ....

and your query logic retrieves it from there.


If you are coding with asp.net you can use MembershipServices and RoleServices. And it is not goog idea to get parameter from master page. If you will use membershipservice. Later you can simply cal it's methods and get currenc logged user.

here is link to learn how to use this services

if you will use it you can simply the call User.Identity.Name and get current user name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜