views:

61

answers:

1

I have a User object on a Base controller, this is the standard type of User object you have with the .Net Membership Provider. I need this is decide if users have access to actions, views, and so on.

I am having a problem whereby I want to display user information on the Masterpage. Like a login view from WebForms. I tried to access the User object from the Masterpage but I can't.

So:

Am I breaking the separation of concerns by checking if the user is logged in on the view (simple if statement which changes what is displayed).

Can I simply access the base controller namespace to access this property or is there something wrong with that? When do the controllers get initialised?

As I write this I consider that having my base controller have this property might be a bad idea on the first place.

AGHH!! How would you handle checking user information to change the Masterpage.

+1  A: 

Use this:

<% var user = ViewContext.HttpContext.User; %>
eu-ge-ne
Thank you muchly
Damien