0

I need to change the layout according the user in the _viewstart.chtml . I have seen the answers in the question Why can't _ViewStart.cshtml access the ViewBag object? and the answers suggests to use ViewContext.ViewBag but in mvc 5 i have the error

An object reference is required for the nonstatic field, method, or property 

So how i can use the viewbag or ViewContext in _viewstart.chtml.

Tareq
  • 1,397
  • 27
  • 28

1 Answers1

0

The code will compile and there's no error in the runtime despite there being an error in the _viewstart code

enter image description here

MaRubl
  • 15
  • 7
Tareq
  • 1,397
  • 27
  • 28