Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BaseControllerConstructor: Constructor
- {
- protected UserProfile _currentUserProfile;
- protected override void Initialize(RequestContext requestContext)
- {
- base.Initialize(requestContext);
- if (User.Identity.IsAuthenticated)
- {
- _currentUserId = User.Identity.GetUserId();
- _currentUserProfile = LoadUserProfile(_currentUserId);
- }
- }
- }
- public BaseControllerConstructor()
- {
- // HttpContext is null
- string _currentUserId = HttpContext.User.GetUserId();
- _currentUserProfile = LoadUserProfile(_currentUserId);
- }
- class Controller: BaseControllerConstructor
- {
- public ActionResult Action()
- {
- foo(_currentUserProfile);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement