2

I would like to change navigation bar in my application depending on who is loged in. I don't want customer to see links available to admin for example. From information that I've found so far I think I will have to create couple of versions of layout and use wright one with appropriate view. If I'm wrong what is the best way to do it?

2
  • Can you provide some details regarding your layout? What is the difference in terms of links changes between normal user and an administrator? Commented Apr 30, 2016 at 16:44
  • @ Alexei I just want to make website look as easy to read and clear as possible, so cutomer does not need to see links for admin for which will have no access anyway. After log in customer enter his part of app and see links that will use and have access to. The same with admin. Commented Apr 30, 2016 at 16:54

1 Answer 1

1

In most Web applications administration area is quite different from "operational" area (that dedicated to normal users). Providing more details might be useful, but I recommend to use areas, a feature of MVC:

  • they allow to have a clear separation by semantics of content. In your case this means administration vs. other parts of the application

  • each area can define a default layout (or other layout pages) to be used in that particular area

  • areas act as containers for security and routes

Using the same layout between administrative and other part of your application might force into ugly code like the following:

if (@Model.IsAdmin)
{
    // show admin link 1 here
}

// normal user or public content here

if (@Model.IsAdmin)
{
    // other code accessible for admin only
}

So, shortly put, I advice for separation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.