If I’m coding in a View in Asp.net MVC and I want to get the current user, is it better to use
Page.User
or
HttpContext.User
Is there a difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Page.Userreturnsthis.Context.Userwhich is exactly the same asHttpContext.User, so it makes no difference, both point to the same object in memory. As a side note, I would recommend you not to use either of these in a View Page, let the controller pass the needed data to the view in which case you have a third choise which is the Controller.User property.