Question

Possible Duplicate:
How to assign Profile values?

I'm using ASP.NET MVC and the Membership providers. How do I get the profile of a user in a view? any particular method to get it?

The template project out of the box access the username in this way:

<%= Html.Encode(Page.User.Identity.Name) %>

I'd like to have a similar way to access the profile data.

Was it helpful?

Solution 3

The way to access the user profile on MVC is through the Profile variable in the view, like this:

<%= Profile %>

OTHER TIPS

In MVC, you shouldn't access the profile directly in the view. You should fill a model object with values of the user profile in the controller and use the view to render those values.

Membership is handled at the server side; if you want that information to be available to the View, then use either your Session or the ViewData dictionary. Before you render the page, put the proper data or object into the ViewData dictionary, or add it as part of the Session. If you are only using in one view, then I recommend ViewData.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top