title: ASP.NET MVC5 Access ViewBag from layout?
body: <p>I'm currently trying to pass dynamic data from my controller to my view AND layout. I'm currently using the ViewBag to pass data from the Controller to the view which works fine. I'm not able to access the ViewBag from within the layout. Is there a way to do this? </p>
  
  <p>I'm using ASP.NET W/ MVC5 (C#).</p>
  
  <p>Edit: Updated W/ code:</p>
  
  <pre><code>//layout.cshtml
  @ViewBag.username
  </code></pre>
  
  <p>Yields this error:</p>
  
  <pre><code>Compilation Error
  Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
  
  Compiler Error Message: CS0103: The name 'ViewBag' does not exist in the current context
  </code></pre>