Skip to main content
Post Made Community Wiki by Venemo
Source Link
Ray Linder
  • 129
  • 2
  • 7

A late post, but for those who searched this post.

Imagine this:

 [Authorize(Roles = "Administrator")] [Authorize(Roles = "Director")] [Authorize(Roles = "Human Resources")] [HttpGet] public ActionResult GetUserData(string UserIdGuidKey) { if (UserIdGuidKey!= null) { var guidUserId = new Guid(UserIdGuidKey); var memuser = Membership.GetUser(guidUserId); var profileuser = Profile.GetUserProfile(memuser.UserName); var list = new { UserName = memuser.UserName, Email = memuser.Email , IsApproved = memuser.IsApproved.ToString() , IsLockedOut = memuser.IsLockedOut.ToString() , LastLockoutDate = memuser.LastLockoutDate.ToString() , CreationDate = memuser.CreationDate.ToString() , LastLoginDate = memuser.LastLoginDate.ToString() , LastActivityDate = memuser.LastActivityDate.ToString() , LastPasswordChangedDate = memuser.LastPasswordChangedDate.ToString() , IsOnline = memuser.IsOnline.ToString() , FirstName = profileuser.FirstName , LastName = profileuser.LastName , NickName = profileuser.NickName , BirthDate = profileuser.BirthDate.ToString() , }; return Json(list, JsonRequestBehavior.AllowGet); } return Redirect("Index"); } 

As you can see, I'm utilizing C# 3.0's feature for creating the "Auto" Generics. It's a bit lazy, but I like it and it works. Just a note: Profile is a custom class I've created for my web application project.