I recently asked a question about using the Page.User or HttpContext.Current.User in the View. It was recommended I pass the user info through the Controller instead? I’ve seen this in other posted answer as well.
Why is it recommended to pass the user info through the controller and not use Page.User or HttpContext.User?
Controller should provide all necessary data for view. This makes views more testable. If you use only view model inside view, you can easily write test:
If you used HttpContext.Current inside of view, you would have to set it up first in your tests, which may not be easy and would add additional dependencies.