Managing two headers in MVC razor

I have two different headers…One header is for home page only and other is for inner pages.When my application starts,it comes to home page which using header1.when user click on any link on home page,it goes to inner pages which has header2.

Header2 is different from header1 as header2 has more html & controls than header1.

How i will manage these two header at once and using _Layout.cshtml?

It’s tough to answer your question without more information on exactly what you’re trying to accomplish.  However a simply if…else should do the trick in the layout page.  If the current request is the "Home" page then render header1 else render header2.

Another method is to create a base controller which does the conditional logic.  Then inherit from the base controller.

Leave a Reply