How to create pages with different permissions' views

不想你离开。 提交于 2019-12-08 08:52:28

问题


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.


回答1:


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");
    }
}


来源:https://stackoverflow.com/questions/5067141/how-to-create-pages-with-different-permissions-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!