1

I need some help to create pages with different views. Don't get me wrong, I don't want anyone to write code for me, I just want to know what I'll need to implement.

I'll detail what I need:

Ex: Facebook page. If I'm at my profile's page I have one type of view, I can edit all my data, see even not set data and add more information. If I'm visiting a friend's page I can only see what he wants me to and interact with his pages as far as he allowed me.

Ex2: One user posted info on some blog. He and all the people with privileges can edit that info, the other can only read and post comments as their permissions allow.

Was I clear enough?

I wasn't able to find Google references because I don't know the name of this technique and the keywords I typed didn't take me anywhere.

I appreciate any help.

Thanks.

eestein
  • 4,914
  • 8
  • 54
  • 93

1 Answers1

2

You can render different views in actions or even redirect to different actions. For Example

public ActionResult Profile()
{
    //Based on business logic, set variables 
    if(userProfile)
    {
        return View("Profile");
    }
    else if(friendProfile)
    {
        return View("FriendProfile");
    }
}
Adeel
  • 19,075
  • 4
  • 46
  • 60
  • Understood. This `if(userHasPermission) loadP1 else loadP2` I was aware of. Is that the (only, best or event a good) way to go using asp.net mvc2? Thanks. – eestein Feb 21 '11 at 14:39