HttpContext.User or Page.User in view?

If I code in a view in MVC Asp.net and I want to get the current user, is it better to use

Page.User

or

HttpContext.User

Is there any difference?

+4
source share
1 answer

Page.User returns this.Context.User , which is exactly the same as HttpContext.User , so it does not matter, both point to the same object in memory. As a note, I would recommend that you not use any of them on the watch page, let the controller pass the necessary data to the view, in which case you have a third choice, which is Controller.User .

+6
source

All Articles