MR.ABC
MR.ABC

Reputation: 4862

MVC Hide navigation for some urls

I have a navigation on my _Layout.cshtml. How can i hide it for some views/urls? Do not want to use javascript for this problem.

Upvotes: 0

Views: 1099

Answers (1)

heymega
heymega

Reputation: 9411

  • Create a different Layout file based on your _Layout.chtml
  • Remove the URLS you don't want.
  • Update your views to use this layout.

Alternatively you can use a model for your layout page but from my experience it isn't worth the hassle.

Update - Example Using A Model in Layout

You essentially use a base model which is used for your layout and your view models inherit from it. Here's a link to another SO question with example code.

Upvotes: 3

Related Questions