Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public class BaseControllerConstructor: Constructor
  2. {
  3. protected UserProfile _currentUserProfile;
  4.  
  5. protected override void Initialize(RequestContext requestContext)
  6. {
  7. base.Initialize(requestContext);
  8.  
  9. if (User.Identity.IsAuthenticated)
  10. {
  11. _currentUserId = User.Identity.GetUserId();
  12. _currentUserProfile = LoadUserProfile(_currentUserId);
  13. }
  14. }
  15. }
  16.  
  17. public BaseControllerConstructor()
  18. {
  19. // HttpContext is null
  20. string _currentUserId = HttpContext.User.GetUserId();
  21. _currentUserProfile = LoadUserProfile(_currentUserId);
  22. }
  23.  
  24. class Controller: BaseControllerConstructor
  25. {
  26. public ActionResult Action()
  27. {
  28. foo(_currentUserProfile);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement